diff --git a/.travis.yml b/.travis.yml index 3da72c7..684881a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,12 @@ git: install: - pip install pipenv - - pipenv install + - pipenv install --dev script: + - pycodestyle $(git ls-files '*.py') + - pydocstyle $(git ls-files '*.py') + - pyflakes $(git ls-files '*.py') - ./manage.py makemigrations website - ./manage.py migrate - ./manage.py test diff --git a/Pipfile b/Pipfile index c53574e..e133923 100644 --- a/Pipfile +++ b/Pipfile @@ -1,17 +1,16 @@ [[source]] - url = "https://pypi.python.org/simple" verify_ssl = true name = "pypi" - [packages] - django = ">=2.2.3" gunicorn = "*" - [dev-packages] +pyflakes = "*" +pydocstyle = "*" +pycodestyle = "*" [requires] python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock index 946ec61..1481c5a 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "2740fee59d1787915703e4a13b1b10e906290b1ad847f2a63fc4649369cc0a5e" + "sha256": "c5767b856fefd1eec5615246f9eeb6a81b4e8f6535ef89823c0a99781066e6b5" }, "pipfile-spec": 6, "requires": { @@ -47,5 +47,36 @@ "version": "==0.3.0" } }, - "develop": {} + "develop": { + "pycodestyle": { + "hashes": [ + "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", + "sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c" + ], + "index": "pypi", + "version": "==2.5.0" + }, + "pydocstyle": { + "hashes": [ + "sha256:58c421dd605eec0bce65df8b8e5371bb7ae421582cdf0ba8d9435ac5b0ffc36a" + ], + "index": "pypi", + "version": "==4.0.0" + }, + "pyflakes": { + "hashes": [ + "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", + "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2" + ], + "index": "pypi", + "version": "==2.1.1" + }, + "snowballstemmer": { + "hashes": [ + "sha256:4f781f26a15a550146d357181b1c894d82c7e9af4bc80de8626e03a76c36b555", + "sha256:9f3b9ffe0809d174f7047e121431acf99c89a7040f0ca84f94ba53a498e6d0c9" + ], + "version": "==1.9.0" + } + } } diff --git a/website/models.py b/website/models.py index 5ff840d..e5e2d9e 100644 --- a/website/models.py +++ b/website/models.py @@ -5,7 +5,7 @@ from django.db.models.signals import post_save from django.dispatch import receiver from django.utils.text import slugify - +import sys class CustomUser(AbstractUser): """ @@ -63,9 +63,27 @@ class Event(models.Model): An event can contain multiple workshops (as long as the workshops are within the event period. + + Three types of events exist. + UNSW info days: No support needed. Students and volunteers can't sign up + School_based_events: volunteer support + UNSW_events: Volunteers and students support needed """ name = models.CharField(max_length=100) + SCHOOL = 'SE' + UNI_INFO = 'UIE' + UNI = 'UE' + + EVENT_TYPES = ( + (SCHOOL, 'School'), + (UNI_INFO, 'Uni_Info'), + (UNI, 'Uni'), + ) + event_types = models.CharField(max_length = 3, + choices = EVENT_TYPES, + default = UNI, + ) start_date = models.DateField() finish_date = models.DateField() owner = models.ForeignKey(Volunteer, on_delete=models.SET_NULL, null=True) @@ -74,10 +92,20 @@ class Event(models.Model): period = models.TextField(verbose_name='availability period') slug = models.SlugField(default='event', unique=False) # url name of event + def __str__(self): """Return a string representation of an event.""" return self.name + def hasWorkshops(self): + if self.event_types == self.UNI_INFO: + #print(self.event_types) + #print(self.UNI_INFO) + #sys.stdout.flush() + return False + else: + return True + def save(self, *args, **kwargs): """Override save to update slug.""" self.slug = slugify(self.name) diff --git a/website/templates/website/event.html b/website/templates/website/event.html index 9d7dbfe..528934d 100644 --- a/website/templates/website/event.html +++ b/website/templates/website/event.html @@ -8,16 +8,18 @@
+ {% if event.hasWorkshops%} Create Workshop + {% endif %} Send status email @@ -32,7 +34,7 @@
{{ event.description }}
- + {% if event.hasWorkshops%}