Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue22 #23

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# created by virtualenv automatically
*
*.pyc
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,60 @@ git pull upstream <branch-name>

## Instructions to run
- TODO

## Instructions to run
### Activate virtual environment
```bash
cd src
source venv/bin/activate
```

### Generate requirements file
```
pip3 freeze > requirements
```
### Activate server
```bash
python3 manage.py runserver
```
### Frontend - React
For changes in react files to be reflected, do the following :
```
cd frontend
npm run dev
```
### Backend - Django
#### Migrations
Every time there is a change in the models, they need to be reflected to the database by running migrations.
```bash
python manage.py makemigrations backend
python manage.py migrate
```
#### Enabling/Disabling browseable API
Uncomment/Comment (respectively) the following lines in `django_react/settings.py`
```python
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
)
}
```

### Testing
Make sure you're in the correct directory:
```bash
cd src
```

Running Tests:
```bash
coverage run --source='.' manage.py test
```
and generate the report:
```bash
coverage html
```
You'll see exactly what to test. If you prefer seeing the report on the command line run:
```bash
coverage report
```
Binary file added src/.coverage
Binary file not shown.
44 changes: 0 additions & 44 deletions src/README.md

This file was deleted.

16 changes: 16 additions & 0 deletions src/artsocwebsite/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for artsocwebsite project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'artsocwebsite.settings')

application = get_asgi_application()
123 changes: 123 additions & 0 deletions src/artsocwebsite/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"""
Django settings for artsocwebsite project.

Generated by 'django-admin startproject' using Django 3.0.7.

For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '@*ugd9l*s%eeabvf0v)@eeb@kk!&i9hc)@j5256#0s_d8mq#w)'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'backend.apps.BackendConfig',
'rest_framework',
'frontend',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'artsocwebsite.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'artsocwebsite.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'
23 changes: 23 additions & 0 deletions src/artsocwebsite/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""artsocwebsite URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path('',include('backend.urls')),
path('',include('frontend.urls')),
]
16 changes: 16 additions & 0 deletions src/artsocwebsite/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for artsocwebsite project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'artsocwebsite.settings')

application = get_wsgi_application()
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions src/backend/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class BackendConfig(AppConfig):
name = 'backend'
26 changes: 26 additions & 0 deletions src/backend/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.0.7 on 2020-06-30 17:38

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Event',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('description', models.TextField()),
('venue', models.CharField(max_length=100)),
('event_time', models.DateTimeField()),
('image_link', models.URLField()),
('created_at', models.DateTimeField(auto_now_add=True)),
],
),
]
10 changes: 10 additions & 0 deletions src/backend/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.db import models

class Event(models.Model):
name = models.CharField(max_length=100)
description = models.TextField()
venue = models.CharField(max_length=100)
event_time = models.DateTimeField()
image_link = models.URLField()
created_at = models.DateTimeField(auto_now_add=True)

7 changes: 7 additions & 0 deletions src/backend/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from rest_framework import serializers
from .models import Event

class EventSerializer(serializers.ModelSerializer):
class Meta:
model = Event
fields = ('id','name','description','event_time','image_link')
File renamed without changes.
6 changes: 6 additions & 0 deletions src/backend/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.urls import path
from . import views

urlpatterns = [
path('api/event/', views.EventListCreate.as_view() ),
]
10 changes: 10 additions & 0 deletions src/backend/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.shortcuts import render
from .models import Event
from .serializers import EventSerializer
from rest_framework import generics

class EventListCreate(generics.ListCreateAPIView):
queryset = Event.objects.all()
serializer_class = EventSerializer

# Create your views here.
Binary file removed src/bin/__pycache__/django-admin.cpython-38.pyc
Binary file not shown.
Loading