From 38405bada075f4d4bfdfa143cad87ad721ca1e8d Mon Sep 17 00:00:00 2001 From: Nishant Nayak Date: Fri, 19 Jan 2024 21:49:24 +0530 Subject: [PATCH] Add achievements models Signed-off-by: Nishant Nayak --- .pre-commit-config.yaml | 10 +- ...er_executivemember_date_joined_and_more.py | 30 +++++ corpus/accounts/models.py | 4 +- corpus/package.json | 2 - corpus/pages/migrations/0001_initial.py | 110 ++++++++++++++++++ corpus/pages/models.py | 50 ++++++++ .../static/img/electrika/first_prize.svg | 2 +- .../templates/static/img/electrika/logo.svg | 2 +- .../static/img/electrika/second_prize.svg | 4 +- 9 files changed, 202 insertions(+), 12 deletions(-) create mode 100644 corpus/accounts/migrations/0003_alter_executivemember_date_joined_and_more.py create mode 100644 corpus/pages/migrations/0001_initial.py create mode 100644 corpus/pages/models.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f6ceec31..cae8a7bb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,7 +42,7 @@ repos: hooks: - id: reorder-python-imports - # Use the following hooks locally to check for issues. These will mostly always fail on CI. + # # Use the following hooks locally to check for issues. These will mostly always fail on CI. # - repo: https://github.com/PyCQA/bandit # rev: 1.7.5 # hooks: @@ -58,7 +58,7 @@ repos: # hooks: # - id: shellcheck - - repo: https://github.com/ecugol/pre-commit-hooks-django - rev: v0.4.0 # Use the ref you want to point at - hooks: - - id: check-untracked-migrations + # - repo: https://github.com/ecugol/pre-commit-hooks-django + # rev: v0.4.0 + # hooks: + # - id: check-untracked-migrations diff --git a/corpus/accounts/migrations/0003_alter_executivemember_date_joined_and_more.py b/corpus/accounts/migrations/0003_alter_executivemember_date_joined_and_more.py new file mode 100644 index 00000000..7d47c4c2 --- /dev/null +++ b/corpus/accounts/migrations/0003_alter_executivemember_date_joined_and_more.py @@ -0,0 +1,30 @@ +# Generated by Django 4.2.7 on 2024-01-19 16:59 +import datetime + +from django.db import migrations +from django.db import models + + +class Migration(migrations.Migration): + + dependencies = [ + ("accounts", "0002_alter_user_email_alter_user_phone_no_executivemember"), + ] + + operations = [ + migrations.AlterField( + model_name="executivemember", + name="date_joined", + field=models.DateTimeField( + default=datetime.datetime(2024, 1, 19, 22, 29, 26, 499748), + verbose_name="Date Joined", + ), + ), + migrations.AlterField( + model_name="executivemember", + name="github", + field=models.CharField( + blank=True, max_length=39, null=True, verbose_name="GitHub Username" + ), + ), + ] diff --git a/corpus/accounts/models.py b/corpus/accounts/models.py index f4269e89..d87cb37c 100644 --- a/corpus/accounts/models.py +++ b/corpus/accounts/models.py @@ -136,7 +136,9 @@ class ExecutiveMember(models.Model): ) # TODO: Phase out with GitHub OAuth details - github = models.CharField(blank=True, null=True, verbose_name="GitHub Username") + github = models.CharField( + max_length=39, blank=True, null=True, verbose_name="GitHub Username" + ) is_nep = models.BooleanField(default=False, verbose_name="Is NEP Member?") date_joined = models.DateTimeField( default=datetime.now(), verbose_name="Date Joined" diff --git a/corpus/package.json b/corpus/package.json index 846432f4..9dbece05 100644 --- a/corpus/package.json +++ b/corpus/package.json @@ -20,5 +20,3 @@ }, "version": "1.0.0" } - - diff --git a/corpus/pages/migrations/0001_initial.py b/corpus/pages/migrations/0001_initial.py new file mode 100644 index 00000000..59df6148 --- /dev/null +++ b/corpus/pages/migrations/0001_initial.py @@ -0,0 +1,110 @@ +# Generated by Django 4.2.7 on 2024-01-19 16:59 +import django.db.models.deletion +from django.conf import settings +from django.db import migrations +from django.db import models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name="Achievement", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.CharField(max_length=128, verbose_name="Title")), + ("date", models.DateField(verbose_name="Date of Achievement")), + ( + "url", + models.URLField(blank=True, null=True, verbose_name="Related URL"), + ), + ("description", models.TextField(verbose_name="Description")), + ( + "user", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + verbose_name="Related User", + ), + ), + ], + ), + migrations.CreateModel( + name="Tag", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "tag", + models.CharField( + choices=[ + ("GSOC", "Google Summer of Code"), + ("IAS SRFP", "IAS Summer Research Fellowship Program"), + ("SB", "Student Branch Award"), + ], + max_length=32, + verbose_name="Tag", + ), + ), + ( + "achievement", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="pages.achievement", + verbose_name="Achievement", + ), + ), + ], + ), + migrations.CreateModel( + name="Publication", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.CharField(max_length=256, verbose_name="Title")), + ("date", models.DateField(verbose_name="Publish Date")), + ("url", models.URLField(verbose_name="URL")), + ("authors", models.CharField(max_length=256, verbose_name="Authors")), + ( + "user", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + verbose_name="Related User", + ), + ), + ], + ), + ] diff --git a/corpus/pages/models.py b/corpus/pages/models.py new file mode 100644 index 00000000..b1d9b4e6 --- /dev/null +++ b/corpus/pages/models.py @@ -0,0 +1,50 @@ +from accounts.models import User +from django.db import models + + +class Achievement(models.Model): + title = models.CharField(max_length=128, verbose_name="Title") + date = models.DateField(verbose_name="Date of Achievement") + url = models.URLField(blank=True, null=True, verbose_name="Related URL") + user = models.ForeignKey( + User, + on_delete=models.CASCADE, + verbose_name="Related User", + blank=True, + null=True, + ) + description = models.TextField(verbose_name="Description") + + def __str__(self): + return self.title + + +class Tag(models.Model): + TAGS = [ + ("GSOC", "Google Summer of Code"), + ("IAS SRFP", "IAS Summer Research Fellowship Program"), + ("SB", "Student Branch Award"), + # TODO: Add more tags + ] + + tag = models.CharField(max_length=32, choices=TAGS, verbose_name="Tag") + achievement = models.ForeignKey( + Achievement, on_delete=models.CASCADE, verbose_name="Achievement" + ) + + +class Publication(models.Model): + title = models.CharField(max_length=256, verbose_name="Title") + date = models.DateField(verbose_name="Publish Date") + url = models.URLField(verbose_name="URL") + authors = models.CharField(max_length=256, verbose_name="Authors") + user = models.ForeignKey( + User, + on_delete=models.CASCADE, + verbose_name="Related User", + blank=True, + null=True, + ) + + def __str__(self): + return self.title diff --git a/corpus/templates/static/img/electrika/first_prize.svg b/corpus/templates/static/img/electrika/first_prize.svg index b280828d..c16b1936 100644 --- a/corpus/templates/static/img/electrika/first_prize.svg +++ b/corpus/templates/static/img/electrika/first_prize.svg @@ -57,4 +57,4 @@ c-0.676,0.48-1.797,0.157-2.359-0.085c0.267-0.863,0.401-1.948,0.307-3.28l2.767,0.003C22.475,6.424,22.23,7.581,21.584,8.039z"/> - \ No newline at end of file + diff --git a/corpus/templates/static/img/electrika/logo.svg b/corpus/templates/static/img/electrika/logo.svg index 03fe3020..577d4d34 100644 --- a/corpus/templates/static/img/electrika/logo.svg +++ b/corpus/templates/static/img/electrika/logo.svg @@ -1 +1 @@ - \ No newline at end of file + diff --git a/corpus/templates/static/img/electrika/second_prize.svg b/corpus/templates/static/img/electrika/second_prize.svg index 5f2ce27d..6597a8a6 100644 --- a/corpus/templates/static/img/electrika/second_prize.svg +++ b/corpus/templates/static/img/electrika/second_prize.svg @@ -1,7 +1,7 @@ - @@ -59,4 +59,4 @@ c-0.119,1.658,0.05,3.01,0.382,4.086C10.413,8.291,9.016,8.694,8.171,8.096z"/> - \ No newline at end of file +