From 36dabc3e15d96f30810f6d02046943fd196fb87c Mon Sep 17 00:00:00 2001 From: Testing wala User Date: Fri, 22 Dec 2023 01:29:41 +0530 Subject: [PATCH] Final Set of All Changes for Sig pages with all necessary additions and code fixes --- corpus/config/admin.py | 2 +- corpus/config/migrations/0001_initial.py | 148 +++++++++++++++++++++++ corpus/config/migrations/__init__.py | 0 corpus/config/models.py | 37 +++--- corpus/corpus/urls.py | 4 - corpus/pages/views.py | 10 +- corpus/templates/pages/index.html | 6 +- corpus/templates/pages/sig.html | 17 ++- 8 files changed, 190 insertions(+), 34 deletions(-) create mode 100644 corpus/config/migrations/0001_initial.py create mode 100644 corpus/config/migrations/__init__.py diff --git a/corpus/config/admin.py b/corpus/config/admin.py index 3790d3a8..720a64eb 100644 --- a/corpus/config/admin.py +++ b/corpus/config/admin.py @@ -12,7 +12,7 @@ class SocietyAdmin(admin.ModelAdmin): class SIGAdmin(admin.ModelAdmin): - list_display = ("id", "name", "about", "what_we_do") + list_display = ("id", "name") list_display_links = ("name",) diff --git a/corpus/config/migrations/0001_initial.py b/corpus/config/migrations/0001_initial.py new file mode 100644 index 00000000..da5a8fe5 --- /dev/null +++ b/corpus/config/migrations/0001_initial.py @@ -0,0 +1,148 @@ +# Generated by Django 4.2.4 on 2023-12-21 19:49 +from django.db import migrations +from django.db import models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name="ModuleConfiguration", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("module_name", models.CharField(max_length=200)), + ("module_enabled", models.BooleanField(default=False)), + ("module_config", models.JSONField()), + ], + ), + migrations.CreateModel( + name="SIG", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "name", + models.CharField(max_length=10, unique=True, verbose_name="Name"), + ), + ("about", models.TextField(default="", verbose_name="About Us")), + ("what_we_do", models.TextField(default="", verbose_name="What We Do")), + ], + options={ + "verbose_name": "SIG", + "verbose_name_plural": "SIGs", + }, + ), + migrations.CreateModel( + name="Society", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "name", + models.CharField( + choices=[ + ("AESS", "Aerospace and Electronic Systems Society"), + ("APS", "Antennas and Propagation Society"), + ("BTS", "Broadcast Technology Society"), + ("CASS", "Circuits and Systems Society"), + ("COM", "Communications Society"), + ("CIS", "Computational Intelligence Society"), + ("CS", "Computer Society"), + ("CTS", "Consumer Technology Society"), + ("CSS", "Control Systems Society"), + ("DEIS", "Dielectrics and Electrical Insulation Society"), + ("ES", "Education Society"), + ("ECS", "Electromagnetic Compatibility Society"), + ("EDS", "Electron Devices Society"), + ("EPS", "Electronics Packing Society"), + ("EMBS", "Engineering in Medicine and Biology Society"), + ("GRSS", "Geoscience and Remote Sensing Society"), + ("IES", "Industrial Electronics Society"), + ("IAS", "Industry Applications Society"), + ("ITS", "Information Theory Society"), + ("IMS", "Instrumentation and Measurement Society"), + ("ITSS", "Intelligent Transportation Systems Society"), + ("MS", "Magnetics Society"), + ("MTTS", "Microwave Theory and Technology Society"), + ("NPSS", "Nuclear and Plasma Sciences Society"), + ("OES", "Oceanic Engineering Society"), + ("PHO", "Photonics Society"), + ("PELS", "Power Electronics Society"), + ("PES", "Power and Energy Society"), + ("PSES", "Product Safety Engineering Society"), + ("PCS", "Professional Communication Society"), + ("RS", "Reliability Society"), + ("RAS", "Robotics and Automation Society"), + ("SPS", "Signal Processing Society"), + ("SSIT", "Society on Social Implications of Technology"), + ("SSCS", "Solid-State Circuits Society"), + ("SMCS", "Systems, Man, and Cybernetics Society"), + ("TEMS", "Technology and Engineering Management Society"), + ( + "UFFCS", + "Ultrasonics, Ferroelectrics, and Frequency Control Society", + ), + ("VT", "Vehicular Technology Society"), + ( + "SIGHT", + "Special Interest Group on Humanitarian Technology", + ), + ("WIE", "Women in Engineering"), + ], + max_length=5, + unique=True, + verbose_name="Name", + ), + ), + ("url", models.URLField(unique=True, verbose_name="URL")), + ( + "image", + models.ImageField(upload_to="img/logo/", verbose_name="Image"), + ), + ( + "dark_image", + models.ImageField( + blank=True, + null=True, + upload_to="img/logo/", + verbose_name="Dark Image", + ), + ), + ("description", models.TextField(verbose_name="Description")), + ( + "sig", + models.IntegerField(default=-1, null=True, verbose_name="SIG ID"), + ), + ], + options={ + "verbose_name": "Society", + "verbose_name_plural": "Societies", + }, + ), + ] diff --git a/corpus/config/migrations/__init__.py b/corpus/config/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/corpus/config/models.py b/corpus/config/models.py index c0ec4da3..530306dc 100644 --- a/corpus/config/models.py +++ b/corpus/config/models.py @@ -3,6 +3,24 @@ DATETIME_FORMAT = "%d-%m-%Y %H:%M:%S" +class SIG(models.Model): + """ + SIG Model. + Defines all sigs that are part of IEEE NITK SB. + """ + + name = models.CharField(verbose_name="Name", max_length=10, unique=True) + about = models.TextField(verbose_name="About Us", default="") + what_we_do = models.TextField(verbose_name="What We Do", default="") + + def __str__(self): + return self.name + + class Meta: + verbose_name = "SIG" + verbose_name_plural = "SIGs" + + class Society(models.Model): """ Society Model. @@ -61,6 +79,7 @@ class Society(models.Model): verbose_name="Dark Image", upload_to="img/logo/", blank=True, null=True ) description = models.TextField(verbose_name="Description") + sig = models.IntegerField(verbose_name="SIG ID", default=-1, null=True) def __str__(self): return self.get_name_display() @@ -70,24 +89,6 @@ class Meta: verbose_name_plural = "Societies" -class SIG(models.Model): - """ - SIG Model. - Defines all sigs that are part of IEEE NITK SB. - """ - - name = models.CharField(verbose_name="Name", max_length=10, unique=True) - about = models.TextField(verbose_name="About Us", default="") - what_we_do = models.TextField(verbose_name="What We Do", default="") - - def __str__(self): - return self.name - - class Meta: - verbose_name = "SIG" - verbose_name_plural = "SIGs" - - class ModuleConfiguration(models.Model): module_name = models.CharField(max_length=200, blank=False, null=False) module_enabled = models.BooleanField(default=False) diff --git a/corpus/corpus/urls.py b/corpus/corpus/urls.py index 9f254525..69778311 100644 --- a/corpus/corpus/urls.py +++ b/corpus/corpus/urls.py @@ -23,8 +23,4 @@ path("accounts/", include("accounts.urls")), path("", include("pages.urls")), path("embedathon/", include("embedathon.urls")), - path( - "", include("pages.urls") - ), # This is after other urls so that "/"" - # doesn't prevent other urls such as embedathon from loading ] diff --git a/corpus/pages/views.py b/corpus/pages/views.py index b73c35c5..9a997921 100644 --- a/corpus/pages/views.py +++ b/corpus/pages/views.py @@ -38,11 +38,17 @@ def impulse(request): def sig(request, sig_name): - sig = get_object_or_404(SIG, name=sig_name) + sig_data = get_object_or_404(SIG, name=sig_name) + + # Retrieve the related society details using the SIG instance + society_linked_to_sig = Society.objects.filter(sig=sig_data.id) + return render( request, "pages/sig.html", { - "sig": sig, + "sig": sig_data, + # Pass the society details to the SIG + "society_linked_to_sig": society_linked_to_sig, }, ) diff --git a/corpus/templates/pages/index.html b/corpus/templates/pages/index.html index 452ea1d2..ea75f914 100644 --- a/corpus/templates/pages/index.html +++ b/corpus/templates/pages/index.html @@ -60,7 +60,7 @@

CompSoc

A conglomeration of students with a passion for Computer Science, Information Technology and Artificial Intelligence

@@ -76,7 +76,7 @@

Diode

A special interest group with a strong interest in the field of Electronics and Electrical Science

@@ -95,7 +95,7 @@

Piston

A team dedicated to the engineering applications of Mechanical, Automation, Civil, Chemical and Material Sciences

diff --git a/corpus/templates/pages/sig.html b/corpus/templates/pages/sig.html index 229e37c8..29048b4d 100644 --- a/corpus/templates/pages/sig.html +++ b/corpus/templates/pages/sig.html @@ -15,13 +15,18 @@
-