diff --git a/hackathon/migrations/0008_auto_20201018_1459.py b/hackathon/migrations/0008_auto_20201018_1459.py new file mode 100644 index 00000000..b3d3c974 --- /dev/null +++ b/hackathon/migrations/0008_auto_20201018_1459.py @@ -0,0 +1,33 @@ +# Generated by Django 3.1.1 on 2020-10-18 14:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hackathon', '0007_auto_20201017_1148'), + ] + + operations = [ + migrations.RenameField( + model_name='hackproject', + old_name='collab_link', + new_name='deployed_url', + ), + migrations.RenameField( + model_name='hackproject', + old_name='github_link', + new_name='github_url', + ), + migrations.AddField( + model_name='hackproject', + name='share_permission', + field=models.BooleanField(default=True), + ), + migrations.AddField( + model_name='hackproject', + name='speaker_name', + field=models.CharField(default='', max_length=225), + ), + ] diff --git a/hackathon/migrations/0009_auto_20201018_1515.py b/hackathon/migrations/0009_auto_20201018_1515.py new file mode 100644 index 00000000..6c0f7baf --- /dev/null +++ b/hackathon/migrations/0009_auto_20201018_1515.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.1 on 2020-10-18 15:15 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hackathon', '0008_auto_20201018_1459'), + ] + + operations = [ + migrations.RemoveField( + model_name='hackproject', + name='created_by', + ), + migrations.RemoveField( + model_name='hackproject', + name='mentor', + ), + migrations.AlterField( + model_name='hackproject', + name='description', + field=models.TextField(max_length=500), + ), + ] diff --git a/hackathon/migrations/0010_merge_20201020_1944.py b/hackathon/migrations/0010_merge_20201020_1944.py new file mode 100644 index 00000000..a62237e2 --- /dev/null +++ b/hackathon/migrations/0010_merge_20201020_1944.py @@ -0,0 +1,14 @@ +# Generated by Django 3.1.1 on 2020-10-20 19:44 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('hackathon', '0009_auto_20201018_1829'), + ('hackathon', '0009_auto_20201018_1515'), + ] + + operations = [ + ] diff --git a/hackathon/migrations/0011_auto_20201020_1948.py b/hackathon/migrations/0011_auto_20201020_1948.py new file mode 100644 index 00000000..3f1dcf3e --- /dev/null +++ b/hackathon/migrations/0011_auto_20201020_1948.py @@ -0,0 +1,32 @@ +# Generated by Django 3.1.1 on 2020-10-20 19:48 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('hackathon', '0010_merge_20201020_1944'), + ] + + operations = [ + migrations.AddField( + model_name='hackproject', + name='created_by', + field=models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, related_name='hackprojects', to='auth.user'), + preserve_default=False, + ), + migrations.AddField( + model_name='hackproject', + name='mentor', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hackproject_mentor', to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='hackprojectscore', + name='created_by', + field=models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscores', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/hackathon/migrations/0012_remove_hackproject_created_by.py b/hackathon/migrations/0012_remove_hackproject_created_by.py new file mode 100644 index 00000000..1927b42f --- /dev/null +++ b/hackathon/migrations/0012_remove_hackproject_created_by.py @@ -0,0 +1,17 @@ +# Generated by Django 3.1.1 on 2020-10-20 19:49 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('hackathon', '0011_auto_20201020_1948'), + ] + + operations = [ + migrations.RemoveField( + model_name='hackproject', + name='created_by', + ), + ] diff --git a/hackathon/migrations/0013_remove_hackproject_mentor.py b/hackathon/migrations/0013_remove_hackproject_mentor.py new file mode 100644 index 00000000..8ea1b471 --- /dev/null +++ b/hackathon/migrations/0013_remove_hackproject_mentor.py @@ -0,0 +1,17 @@ +# Generated by Django 3.1.1 on 2020-10-20 19:52 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('hackathon', '0012_remove_hackproject_created_by'), + ] + + operations = [ + migrations.RemoveField( + model_name='hackproject', + name='mentor', + ), + ] diff --git a/hackathon/migrations/0014_auto_20201020_1953.py b/hackathon/migrations/0014_auto_20201020_1953.py new file mode 100644 index 00000000..d666599d --- /dev/null +++ b/hackathon/migrations/0014_auto_20201020_1953.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.1 on 2020-10-20 19:53 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('hackathon', '0013_remove_hackproject_mentor'), + ] + + operations = [ + migrations.AddField( + model_name='hackproject', + name='created_by', + field=models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, related_name='hackproject', to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='hackproject', + name='mentor', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hackproject_mentor', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/hackathon/migrations/0015_auto_20201020_1955.py b/hackathon/migrations/0015_auto_20201020_1955.py new file mode 100644 index 00000000..c36f70d3 --- /dev/null +++ b/hackathon/migrations/0015_auto_20201020_1955.py @@ -0,0 +1,21 @@ +# Generated by Django 3.1.1 on 2020-10-20 19:55 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('hackathon', '0014_auto_20201020_1953'), + ] + + operations = [ + migrations.AlterField( + model_name='hackproject', + name='created_by', + field=models.ForeignKey(blank=True, default='', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hackproject', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/hackathon/models.py b/hackathon/models.py index f9770b22..ccadfbed 100644 --- a/hackathon/models.py +++ b/hackathon/models.py @@ -1,4 +1,6 @@ from django.db import models +from django.utils import timezone + from accounts.models import CustomUser as User # Optional fields are ony set to deal with object deletion issues. @@ -112,15 +114,19 @@ class HackProject(models.Model): "scores" has been moved to HackProjectScore. See comments there.""" created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) - # Each model can only be created by one user: One To Many - created_by = models.ForeignKey(User, - on_delete=models.CASCADE, - related_name="hackprojects") + created_by = models.ForeignKey( + User, + on_delete=models.SET_NULL, + null=True, + blank=True, + related_name="hackproject",) display_name = models.CharField(default="", max_length=255) - description = models.TextField() - github_link = models.URLField(default="", max_length=255) - collab_link = models.URLField(default="", max_length=255) + description = models.TextField(max_length=500) + github_url = models.URLField(default="", max_length=255) + deployed_url = models.URLField(default="", max_length=255) submission_time = models.DateTimeField(auto_now_add=True) + speaker_name = models.CharField(default="", max_length=225) + share_permission = models.BooleanField(default=True) # A project has one mentor, a mentor has numerous projects: One to Many. mentor = models.ForeignKey(User, null=True, diff --git a/main/settings.py b/main/settings.py index 938b4f24..a8ca2404 100644 --- a/main/settings.py +++ b/main/settings.py @@ -27,6 +27,8 @@ "allauth.account", "allauth.socialaccount", "crispy_forms", + "hackathon", + "submissions", # custom apps 'accounts', diff --git a/main/urls.py b/main/urls.py index ee21b84d..b11fd9cc 100644 --- a/main/urls.py +++ b/main/urls.py @@ -9,4 +9,5 @@ path("resources/", include("resources.urls")), path("hackathon/", include(("hackathon.urls", "hackathon"), namespace='hackathon')), + path("submission/", include("submissions.urls")), ] diff --git a/submissions/__init__.py b/submissions/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/submissions/apps.py b/submissions/apps.py new file mode 100644 index 00000000..65b6e735 --- /dev/null +++ b/submissions/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class HackProjectSubmissionConfig(AppConfig): + name = 'submissions' diff --git a/submissions/forms.py b/submissions/forms.py new file mode 100644 index 00000000..9c68bc01 --- /dev/null +++ b/submissions/forms.py @@ -0,0 +1,30 @@ +from django import forms +from hackathon.models import HackProject + + +class HackProjectSubmissionForm(forms.ModelForm): + class Meta: + model = HackProject + exclude = ('mentor',) + fields = ('display_name', 'description', 'github_url', + 'deployed_url', 'speaker_name','share_permission') + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + placeholders = { + 'display_name': 'Project Name', + 'speaker_name': 'Speaker(s) Name', + 'description': 'Description', + 'github_url': 'GitHub Repository URL', + 'deployed_url': 'Deployed URL', + 'share_permission': 'Share Permission', + } + + self.fields['display_name'].widget.attrs['autofocus'] = True + for field in self.fields: + if self.fields[field].required: + placeholder = f'{placeholders[field]} *' + else: + placeholder = placeholders[field] + self.fields[field].widget.attrs['placeholder'] = placeholder + self.fields[field].label = False diff --git a/submissions/migrations/__init__.py b/submissions/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/submissions/templates/submissions/submit.html b/submissions/templates/submissions/submit.html new file mode 100644 index 00000000..1542c831 --- /dev/null +++ b/submissions/templates/submissions/submit.html @@ -0,0 +1,23 @@ +{% extends "base.html" %} +{% load static %} + +{% block content %} +