add initial models
This commit is contained in:
parent
56ab57f7f5
commit
d0ff75f2c6
14 changed files with 129 additions and 4 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,5 @@
|
||||||
venv/
|
venv/
|
||||||
.idea/
|
.idea/
|
||||||
|
**/__pycache__/**
|
||||||
|
*.sqlite3
|
||||||
|
*.pyc
|
||||||
|
|
|
@ -30,6 +30,11 @@ ALLOWED_HOSTS = []
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
|
OWN_APPS = [
|
||||||
|
'events',
|
||||||
|
'users'
|
||||||
|
]
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
|
@ -37,7 +42,9 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
]
|
] + OWN_APPS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
@ -76,8 +83,12 @@ WSGI_APPLICATION = 'KeRS.wsgi.application'
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
'NAME': 'kers',
|
||||||
|
'USER': 'kers',
|
||||||
|
'PASSWORD': 'kers',
|
||||||
|
'HOST': '127.0.0.1',
|
||||||
|
'PORT': '3306',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,9 @@ Including another URLconf
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path, include
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path('events/', include('events.urls')),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
]
|
]
|
||||||
|
|
3
events/admin.py
Normal file
3
events/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
5
events/apps.py
Normal file
5
events/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class EventsConfig(AppConfig):
|
||||||
|
name = 'events'
|
33
events/migrations/0001_initial.py
Normal file
33
events/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# Generated by Django 3.0.8 on 2020-07-21 20:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('users', '__first__'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Event',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('date', models.DateTimeField()),
|
||||||
|
('capacity', models.IntegerField()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='EventRegistration',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('shirt_size', models.CharField(choices=[('I', 'Interested'), ('A', 'Admitted'), ('D', 'Denied')], max_length=1)),
|
||||||
|
('event_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='events.Event')),
|
||||||
|
('user_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='users.User')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
0
events/migrations/__init__.py
Normal file
0
events/migrations/__init__.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from users.models import User
|
||||||
|
|
||||||
|
|
||||||
|
class Event(models.Model):
|
||||||
|
date = models.DateTimeField()
|
||||||
|
capacity = models.IntegerField()
|
||||||
|
|
||||||
|
|
||||||
|
class EventRegistration(models.Model):
|
||||||
|
REGISTRATION_STATE = (
|
||||||
|
('I', 'Interested'),
|
||||||
|
('A', 'Admitted'),
|
||||||
|
('D', 'Denied'),
|
||||||
|
)
|
||||||
|
event_id = models.ForeignKey(Event, on_delete=models.CASCADE)
|
||||||
|
user_id = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
|
shirt_size = models.CharField(max_length=1, choices=REGISTRATION_STATE)
|
3
events/tests.py
Normal file
3
events/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
7
events/urls.py
Normal file
7
events/urls.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
from django.urls import path
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', views.index, name='index'),
|
||||||
|
]
|
8
events/views.py
Normal file
8
events/views.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
from django.http import HttpResponse
|
||||||
|
|
||||||
|
|
||||||
|
def index(request):
|
||||||
|
return HttpResponse("Hello, world. You're at the polls index.")
|
24
users/migrations/0001_initial.py
Normal file
24
users/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Generated by Django 3.0.8 on 2020-07-21 20:03
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='User',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('zeus_id', models.IntegerField()),
|
||||||
|
('username', models.CharField(max_length=255)),
|
||||||
|
('student_number', models.CharField(max_length=255)),
|
||||||
|
('real_name', models.CharField(max_length=255)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
0
users/migrations/__init__.py
Normal file
0
users/migrations/__init__.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class User(models.Model):
|
||||||
|
zeus_id = models.IntegerField()
|
||||||
|
username = models.CharField(max_length=255) # zeus username
|
||||||
|
student_number = models.CharField(max_length=255)
|
||||||
|
real_name = models.CharField(max_length=255)
|
Loading…
Reference in a new issue