-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4b40eb
commit 98f9637
Showing
9 changed files
with
612 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. | ||
from .models import Committee, CommitteeMember | ||
|
||
admin.site.register(Committee) | ||
admin.site.register(CommitteeMember) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Generated by Django 3.2.6 on 2021-08-19 08:15 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Committee', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('start_year', models.PositiveIntegerField(help_text='The starting year of the committee')), | ||
('current', models.BooleanField(default=False)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='CommitteeMember', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('index', models.PositiveSmallIntegerField(help_text='Ordering to use on the website')), | ||
('position', models.CharField(max_length=100)), | ||
('name', models.CharField(max_length=100)), | ||
('college', models.CharField(blank=True, choices=[('CAI', 'Gonville & Caius'), ('CTH', "St Catharine's"), ('CHR', "Christ's"), ('CHU', 'Churchill'), ('CL', 'Clare'), ('CLH', 'Clare Hall'), ('CC', 'Corpus Christi'), ('DOW', 'Downing'), ('ED', "St Edmund's"), ('EM', 'Emmanuel'), ('F', 'Fitzwilliam'), ('G', 'Girton'), ('HO', 'Homerton'), ('HH', 'Hughes Hall'), ('JE', 'Jesus'), ('JN', "St John's"), ('K', "King's"), ('LC', 'Lucy Cavendish'), ('M', 'Magdalene'), ('MUR', 'Murray Edwards'), ('N', 'Newnham'), ('PEM', 'Pembroke'), ('PET', 'Peterhouse'), ('Q', "Queens'"), ('R', 'Robinson'), ('SE', 'Selwyn'), ('SID', 'Sidney Sussex'), ('TH', 'Trinity Hall'), ('T', 'Trinity'), ('W', 'Wolfson'), ('DAR', 'Darwin'), ('NA', 'N/A')], max_length=6)), | ||
('email', models.CharField(max_length=100, null=True)), | ||
('is_publications', models.BooleanField(default=False)), | ||
('photo', models.CharField(max_length=100, null=True)), | ||
('committee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='committee.committee')), | ||
], | ||
options={ | ||
'ordering': ['index'], | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,27 @@ | ||
from django.db import models | ||
from members.models import COLLEGES | ||
|
||
# Create your models here. | ||
class Committee(models.Model): | ||
"""Represents a whole committee for a given year, e.g. 2021-2022.""" | ||
start_year = models.PositiveIntegerField(help_text="The starting year of the committee") | ||
current = models.BooleanField(default=False) | ||
|
||
def __str__(self): | ||
return f'Committee ({self.start_year} - {self.start_year + 1})' | ||
|
||
class CommitteeMember(models.Model): | ||
"""Represents an individual committee member.""" | ||
index = models.PositiveSmallIntegerField(help_text="Ordering to use on the website") | ||
position = models.CharField(max_length=100) | ||
name = models.CharField(max_length=100) | ||
college = models.CharField(max_length=6, choices=COLLEGES, blank=True) | ||
email = models.CharField(max_length=100, null=True) | ||
is_publications = models.BooleanField(default=False) | ||
photo = models.CharField(max_length=100, null=True) | ||
committee = models.ForeignKey(Committee, on_delete=models.CASCADE) | ||
|
||
class Meta: | ||
ordering = ['index'] | ||
|
||
def __str__(self): | ||
return f'{self.position} ({self.committee.start_year}): {self.name}, {self.college}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,24 @@ | ||
from django.shortcuts import render | ||
from django.http import HttpResponse | ||
from django.template import loader | ||
|
||
# TODO: Make a committee model | ||
from .models import CommitteeMember, Committee | ||
|
||
committee = { | ||
"year": "2021", | ||
"committee": [ | ||
{ | ||
"position": "President", | ||
"name": "Parth Shimpi", | ||
"college": "Gonville and Caius", | ||
"email": "president", | ||
"photo": "parthnew" | ||
}, | ||
{ | ||
"position": "Vice President", | ||
"name": "Kathryn Bowers", | ||
"college": "Magdalene", | ||
"email": "vice-president", | ||
"photo": "kathryn" | ||
}, | ||
{ | ||
"position": "Treasurer", | ||
"name": "Fong Tsz Lo", | ||
"college": "Magdalene", | ||
"email": "junior-treasurer" | ||
}, | ||
{ | ||
"position": "Events Manager", | ||
"name": "Nikita Kamath", | ||
"college": "St Catharine's", | ||
"email": "events-manager", | ||
"photo": "nikita" | ||
}, | ||
{ | ||
"position": "Events Manager", | ||
"name": "Vishal Gupta", | ||
"college": "St John's", | ||
"email": "events-manager", | ||
"photo": "vishal" | ||
}, | ||
{ | ||
"position": "External Secretary", | ||
"name": "Yan Yau Cheng", | ||
"college": "Magdalene", | ||
"email": "external-secretary", | ||
"photo": "yan-yau" | ||
}, | ||
{ | ||
"position": "Internal Secretary", | ||
"name": "Ashutosh Tripathi", | ||
"college": "Emmanuel", | ||
"email": "internal-secretary" | ||
}, | ||
{ | ||
"position": "Publicity Officer", | ||
"name": "Gesa Dünnweber", | ||
"college": "Gonville and Caius", | ||
"email": "publicity", | ||
"photo": "gesa" | ||
}, | ||
{ | ||
"position": "Sponsorship Officer", | ||
"name": "Etaash Katiyar", | ||
"college":"Corpus Christi", | ||
"email":"corporate-officer" | ||
}, | ||
{ | ||
"position": "Webmaster", | ||
"name": "Adam Kelly", | ||
"college": "Gonville and Caius", | ||
"email": "webmaster" | ||
} | ||
], | ||
"publications": [ | ||
{ | ||
"position": "Eureka Editor", | ||
"name": "Valentin Hübner", | ||
"college": "Pembroke", | ||
"email": "eureka-editor" | ||
} | ||
] | ||
} | ||
def index(request): | ||
page_data = { "committee": [], "publications": [] } | ||
|
||
committee = Committee.objects.filter(current=True) | ||
|
||
if len(committee) == 0: | ||
return render(request, 'committee/index.html', {}) | ||
|
||
page_data["year"] = committee[0].start_year | ||
|
||
def index(request): | ||
return render(request, 'committee/index.html', committee) | ||
committee_members = CommitteeMember.objects.filter(committee_id=committee[0].id) | ||
|
||
for member in committee_members: | ||
type = "committee" if not member.is_publications else "publications" | ||
page_data[type].append(member) | ||
|
||
return render(request, 'committee/index.html', page_data) | ||
|
||
def past(request): | ||
return render(request, 'committee/past.html') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.