From 7c511123bd14a4f6d439f1c64b89e808816a3b44 Mon Sep 17 00:00:00 2001 From: Ali Karbassi Date: Sun, 5 Jan 2020 13:16:30 -0600 Subject: [PATCH 1/3] Deleting squashed migrations. --- .../migrations/0029_course_duration.py | 19 ------- .../migrations/0030_auto_20200101_2217.py | 28 ---------- .../migrations/0031_auto_20200101_2218.py | 28 ---------- .../migrations/0032_auto_20200101_2221.py | 23 -------- .../migrations/0033_auto_20200101_2222.py | 24 --------- .../migrations/0034_auto_20200101_2225.py | 24 --------- .../migrations/0035_auto_20200101_2230.py | 24 --------- .../migrations/0036_auto_20200101_2238.py | 18 ------- .../migrations/0037_auto_20200101_2239.py | 18 ------- .../migrations/0038_auto_20200102_1332.py | 52 ------------------- .../migrations/0039_auto_20200102_1655.py | 33 ------------ .../migrations/0040_auto_20200102_1801.py | 29 ----------- 12 files changed, 320 deletions(-) delete mode 100644 coderdojochi/migrations/0029_course_duration.py delete mode 100644 coderdojochi/migrations/0030_auto_20200101_2217.py delete mode 100644 coderdojochi/migrations/0031_auto_20200101_2218.py delete mode 100644 coderdojochi/migrations/0032_auto_20200101_2221.py delete mode 100644 coderdojochi/migrations/0033_auto_20200101_2222.py delete mode 100644 coderdojochi/migrations/0034_auto_20200101_2225.py delete mode 100644 coderdojochi/migrations/0035_auto_20200101_2230.py delete mode 100644 coderdojochi/migrations/0036_auto_20200101_2238.py delete mode 100644 coderdojochi/migrations/0037_auto_20200101_2239.py delete mode 100644 coderdojochi/migrations/0038_auto_20200102_1332.py delete mode 100644 coderdojochi/migrations/0039_auto_20200102_1655.py delete mode 100644 coderdojochi/migrations/0040_auto_20200102_1801.py diff --git a/coderdojochi/migrations/0029_course_duration.py b/coderdojochi/migrations/0029_course_duration.py deleted file mode 100644 index a0213486..00000000 --- a/coderdojochi/migrations/0029_course_duration.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-02 04:16 - -import datetime -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('coderdojochi', '0028_rename_race_ethnicity'), - ] - - operations = [ - migrations.AddField( - model_name='course', - name='duration', - field=models.DurationField(default=datetime.timedelta(0, 10800), help_text='HH:MM:ss'), - ), - ] diff --git a/coderdojochi/migrations/0030_auto_20200101_2217.py b/coderdojochi/migrations/0030_auto_20200101_2217.py deleted file mode 100644 index 070b26a7..00000000 --- a/coderdojochi/migrations/0030_auto_20200101_2217.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-02 04:17 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('coderdojochi', '0029_course_duration'), - ] - - operations = [ - migrations.RenameField( - model_name='session', - old_name='end_date', - new_name='old_end_date', - ), - migrations.RenameField( - model_name='session', - old_name='mentor_end_date', - new_name='old_mentor_end_date', - ), - migrations.RenameField( - model_name='session', - old_name='mentor_start_date', - new_name='old_mentor_start_date', - ), - ] diff --git a/coderdojochi/migrations/0031_auto_20200101_2218.py b/coderdojochi/migrations/0031_auto_20200101_2218.py deleted file mode 100644 index 213f6b96..00000000 --- a/coderdojochi/migrations/0031_auto_20200101_2218.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-02 04:18 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('coderdojochi', '0030_auto_20200101_2217'), - ] - - operations = [ - migrations.AlterField( - model_name='session', - name='old_end_date', - field=models.DateTimeField(blank=True, null=True), - ), - migrations.AlterField( - model_name='session', - name='old_mentor_end_date', - field=models.DateTimeField(blank=True, null=True), - ), - migrations.AlterField( - model_name='session', - name='old_mentor_start_date', - field=models.DateTimeField(blank=True, null=True), - ), - ] diff --git a/coderdojochi/migrations/0032_auto_20200101_2221.py b/coderdojochi/migrations/0032_auto_20200101_2221.py deleted file mode 100644 index 98585115..00000000 --- a/coderdojochi/migrations/0032_auto_20200101_2221.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-02 04:21 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('coderdojochi', '0031_auto_20200101_2218'), - ] - - operations = [ - migrations.RenameField( - model_name='session', - old_name='max_age_limitation', - new_name='override_max_age_limitation', - ), - migrations.RenameField( - model_name='session', - old_name='min_age_limitation', - new_name='override_min_age_limitation', - ), - ] diff --git a/coderdojochi/migrations/0033_auto_20200101_2222.py b/coderdojochi/migrations/0033_auto_20200101_2222.py deleted file mode 100644 index d86728f6..00000000 --- a/coderdojochi/migrations/0033_auto_20200101_2222.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-02 04:22 - -import django.core.validators -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('coderdojochi', '0032_auto_20200101_2221'), - ] - - operations = [ - migrations.AlterField( - model_name='session', - name='override_max_age_limitation', - field=models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)]), - ), - migrations.AlterField( - model_name='session', - name='override_min_age_limitation', - field=models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)]), - ), - ] diff --git a/coderdojochi/migrations/0034_auto_20200101_2225.py b/coderdojochi/migrations/0034_auto_20200101_2225.py deleted file mode 100644 index 422dc19a..00000000 --- a/coderdojochi/migrations/0034_auto_20200101_2225.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-02 04:25 - -import django.core.validators -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('coderdojochi', '0033_auto_20200101_2222'), - ] - - operations = [ - migrations.AlterField( - model_name='session', - name='override_max_age_limitation', - field=models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)], verbose_name='Max Age'), - ), - migrations.AlterField( - model_name='session', - name='override_min_age_limitation', - field=models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)], verbose_name='Min Age'), - ), - ] diff --git a/coderdojochi/migrations/0035_auto_20200101_2230.py b/coderdojochi/migrations/0035_auto_20200101_2230.py deleted file mode 100644 index 29fccb13..00000000 --- a/coderdojochi/migrations/0035_auto_20200101_2230.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-02 04:30 - -import django.core.validators -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('coderdojochi', '0034_auto_20200101_2225'), - ] - - operations = [ - migrations.AddField( - model_name='course', - name='maximum_age', - field=models.IntegerField(default=17, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)]), - ), - migrations.AddField( - model_name='course', - name='minimum_age', - field=models.IntegerField(default=7, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)]), - ), - ] diff --git a/coderdojochi/migrations/0036_auto_20200101_2238.py b/coderdojochi/migrations/0036_auto_20200101_2238.py deleted file mode 100644 index f86856c3..00000000 --- a/coderdojochi/migrations/0036_auto_20200101_2238.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-02 04:38 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('coderdojochi', '0035_auto_20200101_2230'), - ] - - operations = [ - migrations.AlterField( - model_name='session', - name='cost', - field=models.DecimalField(blank=True, decimal_places=2, max_digits=6, null=True), - ), - ] diff --git a/coderdojochi/migrations/0037_auto_20200101_2239.py b/coderdojochi/migrations/0037_auto_20200101_2239.py deleted file mode 100644 index 9a4c66e8..00000000 --- a/coderdojochi/migrations/0037_auto_20200101_2239.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-02 04:39 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('coderdojochi', '0036_auto_20200101_2238'), - ] - - operations = [ - migrations.RenameField( - model_name='equipment', - old_name='aquisition_date', - new_name='acquisition_date', - ), - ] diff --git a/coderdojochi/migrations/0038_auto_20200102_1332.py b/coderdojochi/migrations/0038_auto_20200102_1332.py deleted file mode 100644 index 7a5adc7a..00000000 --- a/coderdojochi/migrations/0038_auto_20200102_1332.py +++ /dev/null @@ -1,52 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-02 19:32 - -from django.db import migrations, models -import django.utils.timezone - - -class Migration(migrations.Migration): - - dependencies = [ - ('coderdojochi', '0037_auto_20200101_2239'), - ] - - operations = [ - migrations.AddField( - model_name='equipmenttype', - name='created_at', - field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), - preserve_default=False, - ), - migrations.AddField( - model_name='equipmenttype', - name='updated_at', - field=models.DateTimeField(auto_now=True), - ), - migrations.AddField( - model_name='location', - name='created_at', - field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), - preserve_default=False, - ), - migrations.AddField( - model_name='location', - name='updated_at', - field=models.DateTimeField(auto_now=True), - ), - migrations.AddField( - model_name='partnerpasswordaccess', - name='updated_at', - field=models.DateTimeField(auto_now=True), - ), - migrations.AddField( - model_name='raceethnicity', - name='created_at', - field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), - preserve_default=False, - ), - migrations.AddField( - model_name='raceethnicity', - name='updated_at', - field=models.DateTimeField(auto_now=True), - ), - ] diff --git a/coderdojochi/migrations/0039_auto_20200102_1655.py b/coderdojochi/migrations/0039_auto_20200102_1655.py deleted file mode 100644 index 5f9e53f9..00000000 --- a/coderdojochi/migrations/0039_auto_20200102_1655.py +++ /dev/null @@ -1,33 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-02 22:55 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('coderdojochi', '0038_auto_20200102_1332'), - ] - - operations = [ - migrations.RenameField( - model_name='session', - old_name='max_cost', - new_name='maximum_cost', - ), - migrations.RenameField( - model_name='session', - old_name='min_cost', - new_name='minimum_cost', - ), - migrations.RenameField( - model_name='session', - old_name='override_max_age_limitation', - new_name='override_maximum_age_limitation', - ), - migrations.RenameField( - model_name='session', - old_name='override_min_age_limitation', - new_name='override_minimum_age_limitation', - ), - ] diff --git a/coderdojochi/migrations/0040_auto_20200102_1801.py b/coderdojochi/migrations/0040_auto_20200102_1801.py deleted file mode 100644 index fc55c55d..00000000 --- a/coderdojochi/migrations/0040_auto_20200102_1801.py +++ /dev/null @@ -1,29 +0,0 @@ -# Generated by Django 2.2.9 on 2020-01-03 00:01 - -import django.core.validators -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('coderdojochi', '0039_auto_20200102_1655'), - ] - - operations = [ - migrations.AlterField( - model_name='session', - name='gender_limitation', - field=models.CharField(blank=True, choices=[('male', 'Male'), ('female', 'Female')], help_text='Limits the class to be only one gender.', max_length=255, null=True), - ), - migrations.AlterField( - model_name='session', - name='override_maximum_age_limitation', - field=models.IntegerField(blank=True, help_text='Only update this if different from the default.', null=True, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)], verbose_name='Max Age'), - ), - migrations.AlterField( - model_name='session', - name='override_minimum_age_limitation', - field=models.IntegerField(blank=True, help_text='Only update this if different from the default.', null=True, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)], verbose_name='Min Age'), - ), - ] From d8b216d5a0e4fcb399bb2d8e055b1112a4e72f02 Mon Sep 17 00:00:00 2001 From: Ali Karbassi Date: Sun, 5 Jan 2020 13:16:52 -0600 Subject: [PATCH 2/3] Fixing DB connection string in settings. --- .env.sample | 6 ++++++ Pipfile.lock | 2 +- coderdojochi/settings.py | 26 +++++++++++++++++++++----- docker-compose.yml | 5 ++++- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.env.sample b/.env.sample index 6260201a..3047cb0a 100644 --- a/.env.sample +++ b/.env.sample @@ -1,11 +1,13 @@ DEBUG=True ENABLE_DEV_FIXTURES=True + SITE_NAME=We All Code SITE_URL=http://localhost:8000 SECRET_KEY=CHANGEME DJANGO_SECURE_SSL_REDIRECT=False + # Database POSTGRES_HOST=db POSTGRES_PORT=5432 @@ -13,20 +15,24 @@ POSTGRES_DB=postgres POSTGRES_USER=postgres POSTGRES_PASSWORD=mysecretpassword + # Email DEFAULT_FROM_EMAIL=hello+local@weallcode.org CONTACT_EMAIL=hello+local@weallcode.org SENDGRID_API_KEY=CHANGEME SENDGRID_UNSUB_CLASSANNOUNCE=1234567890 + # AWS AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_STORAGE_BUCKET_NAME= + # Sentry SENTRY_DSN= + # reCAPTCHA RECAPTCHA_PUBLIC_KEY= RECAPTCHA_PRIVATE_KEY= diff --git a/Pipfile.lock b/Pipfile.lock index 7d7ffd3d..8324a4d2 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -232,7 +232,7 @@ "et-xmlfile": { "hashes": [ "sha256:614d9722d572f6246302c4491846d2c393c199cfa4edc9af593437691683335b", - "sha256:e465dc95c37d9e1905a940b7b87e13d7c60d83e38673519101fad2df0563233d" + "sha256:820bb57cd625d1da88014078a66c5c26267bda7a2234b7211c5d2bd15db5f6c7" ], "version": "==1.0.1" }, diff --git a/coderdojochi/settings.py b/coderdojochi/settings.py index 9a7dfdd6..ca91234b 100644 --- a/coderdojochi/settings.py +++ b/coderdojochi/settings.py @@ -12,7 +12,6 @@ import os -import dj_database_url import django_heroku import environ import raven @@ -159,9 +158,29 @@ # Database # https://docs.djangoproject.com/en/2.0/ref/settings/#databases -DATABASES = {"default": env.db("DATABASE_URL")} +# DATABASES = {"default": env.db("DATABASE_URL")} +POSTGRES_HOST = env('POSTGRES_HOST', default='') +POSTGRES_PORT = env.int('POSTGRES_PORT', default=5432) +POSTGRES_DB = env('POSTGRES_DB', default='') +POSTGRES_USER = env('POSTGRES_USER', default='') +POSTGRES_PASSWORD = env('POSTGRES_PASSWORD', default='') + +# Use DATABASE_URL other wise create connection string +DATABASES = { + 'default': env.db( + 'DATABASE_URL', + default=f'postgres://{POSTGRES_USER}:{POSTGRES_PASSWORD}@{POSTGRES_HOST}:{POSTGRES_PORT}/{POSTGRES_DB}' + ) +} + DATABASES["default"]["ATOMIC_REQUESTS"] = True +# Change 'default' database configuration with $DATABASE_URL. +if not DEBUG: + DATABASES['default']['CONN_MAX_AGE'] = env.int('CONN_MAX_AGE', default=60) + DATABASES['default']['SSL_REQUIRE'] = env.bool('SSL_REQUIRE', default=True) + + # Password validation # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators @@ -194,9 +213,6 @@ SITE_NAME = env('SITE_NAME', default=None) SITE_URL = env('SITE_URL', default=None) -# Change 'default' database configuration with $DATABASE_URL. -DATABASES['default'].update(dj_database_url.config(conn_max_age=500, ssl_require=True)) - # Honor the 'X-Forwarded-Proto' header for request.is_secure() SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') diff --git a/docker-compose.yml b/docker-compose.yml index 786b9c48..7cddfb72 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,8 @@ services: app: restart: always build: . - env_file: .env + env_file: + - .env container_name: dojo-v1-app command: invoke release start volumes: @@ -16,5 +17,7 @@ services: db: image: postgres:10.6-alpine container_name: dojo-v1-db + env_file: + - .env ports: - "5432:5432" From e02fd158db04601d993f3752dcaa35787f14975a Mon Sep 17 00:00:00 2001 From: Ali Karbassi Date: Sun, 23 Feb 2020 21:55:09 -0600 Subject: [PATCH 3/3] WIP --- .vscode/settings.json | 28 +++++++++++ coderdojochi/admin.py | 8 +-- .../migrations/0030_session_release_date.py | 50 +++++++++++++++++++ coderdojochi/models.py | 24 ++++++++- .../templates/guardian/session-detail.html | 5 ++ coderdojochi/views/sessions.py | 7 --- fixtures/01-auth.group.json | 14 +++--- fixtures/13-coderdojochi.session.json | 30 ++++++----- fixtures/get.sh | 2 +- 9 files changed, 136 insertions(+), 32 deletions(-) create mode 100644 coderdojochi/migrations/0030_session_release_date.py diff --git a/.vscode/settings.json b/.vscode/settings.json index fea38df7..4a83bc3d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -52,4 +52,32 @@ "editor.quickSuggestions": false, "editor.trimAutoWhitespace": false, }, + "cSpell.words": [ + "authed", + "Boto", + "coderodojochi", + "dateutil", + "dtend", + "favicon", + "favicons", + "gunicorn", + "Hmmss", + "iaarj", + "icalendar", + "loginas", + "mstile", + "noqa", + "pjpeg", + "PROTO", + "pytz", + "REFERER", + "Signup", + "strftime", + "strptime", + "strptime", + "strtobool", + "strtobool", + "unauthed", + "YYYYMMDDTH", + ], } diff --git a/coderdojochi/admin.py b/coderdojochi/admin.py index 8af6694e..af857170 100644 --- a/coderdojochi/admin.py +++ b/coderdojochi/admin.py @@ -514,7 +514,6 @@ class SessionAdmin(ImportExportMixin, ImportExportActionModelAdmin): list_display = [ '_course', 'start_date', - # 'end_date', 'location', 'capacity', 'student_count_link', @@ -568,9 +567,7 @@ class SessionAdmin(ImportExportMixin, ImportExportActionModelAdmin): 'course', 'location', 'start_date', - # 'old_end_date', - # 'old_mentor_start_date', - # 'old_mentor_end_date', + 'release_date', 'capacity', 'mentor_capacity', 'instructor', @@ -602,6 +599,9 @@ class SessionAdmin(ImportExportMixin, ImportExportActionModelAdmin): 'announced_date_guardians', 'mentors_week_reminder_sent', 'mentors_day_reminder_sent', + # 'old_end_date', + # 'old_mentor_start_date', + # 'old_mentor_end_date', ), }), ) diff --git a/coderdojochi/migrations/0030_session_release_date.py b/coderdojochi/migrations/0030_session_release_date.py new file mode 100644 index 00000000..73c1e9e2 --- /dev/null +++ b/coderdojochi/migrations/0030_session_release_date.py @@ -0,0 +1,50 @@ +# Generated by Django 2.2.9 on 2020-01-05 23:20 + +import django.utils.timezone +from django.db import migrations, models + + +class Migration(migrations.Migration): + + def set_release_date_if_null(apps, schema_editor): + Session = apps.get_model('coderdojochi', 'Session') + + for session in Session.objects.filter().iterator(): + # If the start_date is in the past, set release_date to the start_date + if session.start_date <= timezone.now() and session.announced_date_guardians: + session.release_date = session.announced_date_guardians + else: + # Subtract 1 week + session.release_date = session.start_date - timedelta(weeks=1) + + # If it's not on a monday, go to the previous monday + session.release_date -= timedelta(days=session.release_date.weekday()) + + # Set it to 9am of that day + session.release_date = session.release_date.replace(hour=9) + + session.save() + + + def reverse_set_release_date_if_null(apps, schema_editor): + pass # code for reverting migration, if any + + + dependencies = [ + ('coderdojochi', '0029_course_duration_squashed_0040_auto_20200102_1801'), + ] + + operations = [ + migrations.AddField( + model_name='session', + name='release_date', + field=models.DateTimeField(null=True, blank=True, help_text="The date guardians can sign up. If not set, the system will pick 1 week (Monday) from 'Start Date'."), + preserve_default=False, + ), + migrations.RunPython(set_release_date_if_null, reverse_set_release_date_if_null), + migrations.AlterField( + model_name='session', + name='release_date', + field=models.DateTimeField(blank=True, help_text="The date guardians can sign up. If not set, the system will pick 1 week (Monday) from 'Start Date'."), + ), + ] diff --git a/coderdojochi/models.py b/coderdojochi/models.py index 338be895..3e094bbe 100644 --- a/coderdojochi/models.py +++ b/coderdojochi/models.py @@ -10,6 +10,7 @@ from django.urls import reverse from django.utils import formats, timezone from django.utils.translation import ugettext as _ + from stdimage.models import StdImageField @@ -496,6 +497,11 @@ class Session(CommonInfo): start_date = models.DateTimeField() + release_date = models.DateTimeField( + blank=True, + help_text="The date guardians can sign up. If not set, the system will pick 1 week (Monday) from 'Start Date'.", + ) + location = models.ForeignKey( Location, on_delete=models.CASCADE, @@ -665,10 +671,23 @@ def __str__(self): return f"{self.course.title} | {date}" def save(self, *args, **kwargs): + + # Set mentor capacity if not set if self.mentor_capacity is None: self.mentor_capacity = int(self.capacity / 2) - super(Session, self).save(*args, **kwargs) + # Set release date if not set + if self.release_date is None: + # Subtract 1 week + self.release_date = self.start_date - timedelta(weeks=1) + + # If it's not on a monday, go to the previous monday + self.release_date -= timedelta(days=self.release_date.weekday()) + + # Set it to 9am of that day + self.release_date = self.release_date.replace(hour=9) + + super().save(*args, **kwargs) def get_absolute_url(self): return reverse('session-detail', args=[str(self.id)]) @@ -755,6 +774,9 @@ def is_guardian_announced(self): is_guardian_announced.short_description = "Is Announced" is_guardian_announced.admin_order_field = 'announced_date_guardians' + def is_released(self, *args, **kwargs): + return self.release_date > timezone.now() + @property def end_date(self): # Some records have a defined record with the end date, diff --git a/coderdojochi/templates/guardian/session-detail.html b/coderdojochi/templates/guardian/session-detail.html index 19d491cb..157c8447 100644 --- a/coderdojochi/templates/guardian/session-detail.html +++ b/coderdojochi/templates/guardian/session-detail.html @@ -31,6 +31,11 @@

Class Details & Enrollment

There are currently no available spots for this class. Please enroll in an upcoming class.

+ {% elif session.is_released %} + +

Enroll

+

This class isn't available for sign up just yet. Registration will be available on {{ session.release_date }}

+ {% else %} {% if students %} diff --git a/coderdojochi/views/sessions.py b/coderdojochi/views/sessions.py index eed0eed6..0141b76c 100644 --- a/coderdojochi/views/sessions.py +++ b/coderdojochi/views/sessions.py @@ -231,12 +231,6 @@ def get_context_data(self, **kwargs): session_obj = kwargs['session_obj'] context['session'] = session_obj - upcoming_classes = Session.objects.filter( - is_active=True, - start_date__gte=timezone.now() - ).order_by('start_date') - context['upcoming_classes'] = upcoming_classes - active_mentors = Mentor.objects.filter( id__in=MentorOrder.objects.filter( session=session_obj, @@ -268,7 +262,6 @@ def get_context_data(self, **kwargs): ) context['account'] = account else: - context['upcoming_classes'] = upcoming_classes.filter(is_public=True) context['spots_remaining'] = ( session_obj.capacity - session_obj.get_current_students().count() diff --git a/fixtures/01-auth.group.json b/fixtures/01-auth.group.json index 20c1d15b..f93afe32 100644 --- a/fixtures/01-auth.group.json +++ b/fixtures/01-auth.group.json @@ -6,6 +6,10 @@ "name": "Committee Head", "permissions": [ 35, + 49, + 50, + 51, + 52, 53, 54, 55, @@ -22,10 +26,6 @@ 67, 68, 69, - 49, - 50, - 51, - 52, 38, 41, 44, @@ -43,6 +43,9 @@ "permissions": [ 29, 30, + 49, + 50, + 52, 53, 54, 58, @@ -57,9 +60,6 @@ 69, 100, 101, - 49, - 50, - 52, 28, 37, 38, diff --git a/fixtures/13-coderdojochi.session.json b/fixtures/13-coderdojochi.session.json index 3a36f925..e080bfe6 100644 --- a/fixtures/13-coderdojochi.session.json +++ b/fixtures/13-coderdojochi.session.json @@ -4,12 +4,13 @@ "pk": 1, "fields": { "created_at": "2000-01-01T06:00:00Z", - "updated_at": "2000-01-01T06:00:00Z", + "updated_at": "2020-01-05T23:39:32.030Z", "course": 1, "start_date": "2020-01-01T16:00:00Z", + "release_date": "2020-01-01T16:00:00Z", "location": 1, "capacity": 20, - "mentor_capacity": null, + "mentor_capacity": 10, "instructor": 1, "cost": "0.00", "minimum_cost": null, @@ -41,12 +42,13 @@ "pk": 2, "fields": { "created_at": "2000-01-01T06:00:00Z", - "updated_at": "2000-01-01T06:00:00Z", + "updated_at": "2020-01-05T23:39:32.033Z", "course": 1, "start_date": "2020-02-02T16:00:00Z", + "release_date": "2020-01-20T09:00:00Z", "location": 1, "capacity": 20, - "mentor_capacity": null, + "mentor_capacity": 10, "instructor": 1, "cost": "0.00", "minimum_cost": null, @@ -78,12 +80,13 @@ "pk": 3, "fields": { "created_at": "2000-01-01T06:00:00Z", - "updated_at": "2000-01-01T06:00:00Z", + "updated_at": "2020-01-05T23:39:32.035Z", "course": 1, "start_date": "2020-03-03T16:00:00Z", + "release_date": "2020-02-24T09:00:00Z", "location": 2, "capacity": 20, - "mentor_capacity": null, + "mentor_capacity": 10, "instructor": 1, "cost": "0.00", "minimum_cost": null, @@ -115,12 +118,13 @@ "pk": 4, "fields": { "created_at": "2000-01-01T06:00:00Z", - "updated_at": "2000-01-01T06:00:00Z", + "updated_at": "2020-01-05T23:39:32.037Z", "course": 1, "start_date": "2020-04-04T15:00:00Z", + "release_date": "2020-03-23T09:00:00Z", "location": 1, "capacity": 20, - "mentor_capacity": null, + "mentor_capacity": 10, "instructor": 1, "cost": "0.00", "minimum_cost": null, @@ -152,12 +156,13 @@ "pk": 5, "fields": { "created_at": "2000-01-01T06:00:00Z", - "updated_at": "2000-01-01T06:00:00Z", + "updated_at": "2020-01-05T23:39:32.038Z", "course": 1, "start_date": "2020-05-05T16:00:00Z", + "release_date": "2020-04-27T09:00:00Z", "location": 1, "capacity": 20, - "mentor_capacity": null, + "mentor_capacity": 10, "instructor": 1, "cost": "0.00", "minimum_cost": null, @@ -189,12 +194,13 @@ "pk": 6, "fields": { "created_at": "2000-01-01T06:00:00Z", - "updated_at": "2000-01-01T06:00:00Z", + "updated_at": "2020-01-05T23:39:32.040Z", "course": 2, "start_date": "2020-07-06T15:00:00Z", + "release_date": "2020-06-29T09:00:00Z", "location": 2, "capacity": 20, - "mentor_capacity": null, + "mentor_capacity": 10, "instructor": 1, "cost": "0.00", "minimum_cost": null, diff --git a/fixtures/get.sh b/fixtures/get.sh index 9b27e3c5..95d33614 100755 --- a/fixtures/get.sh +++ b/fixtures/get.sh @@ -1,7 +1,7 @@ #/bin/env bash # To run: -# docker-compuse run --rm app bash ./fixtures/get.sh +# /usr/bin/time -p docker-compose run --rm app bash ./fixtures/get.sh && say "Done" # models=(