From adf59ac9ebab30855984d66fe57d4158e274d365 Mon Sep 17 00:00:00 2001 From: Vignaraj-pai Date: Wed, 17 Jan 2024 14:31:23 +0530 Subject: [PATCH 01/12] Fixed registration issue in Electrika. Info Update on Home page --- corpus/electrika/urls.py | 5 --- corpus/electrika/views.py | 65 +++------------------------- corpus/templates/electrika/home.html | 8 ++-- 3 files changed, 11 insertions(+), 67 deletions(-) diff --git a/corpus/electrika/urls.py b/corpus/electrika/urls.py index e8ce698b..857b5063 100644 --- a/corpus/electrika/urls.py +++ b/corpus/electrika/urls.py @@ -31,9 +31,4 @@ views.delete_announcement, name="electrika_delete_announcement", ), - path( - "admin/team/download_csv", - views.team_download, - name="electrika_admin_download_teams_csv", - ), ] diff --git a/corpus/electrika/views.py b/corpus/electrika/views.py index cf93ff80..2a031e8f 100644 --- a/corpus/electrika/views.py +++ b/corpus/electrika/views.py @@ -34,7 +34,9 @@ def home(request): try: if request.user.is_authenticated: + electrika_user = ElectrikaUser.objects.get(user=request.user) args["registered"] = True + args["electrika_user"] = electrika_user except ElectrikaUser.DoesNotExist: args["registered"] = False @@ -143,6 +145,10 @@ def index(request): @login_required @module_enabled(module_name="electrika") def register(request): + + next_param = request.GET.get('next', '/') + request.session['registration_next'] = next_param + config = ModuleConfiguration.objects.get(module_name="electrika").module_config reg_start_datetime, reg_end_datetime = ( @@ -499,61 +505,4 @@ def delete_announcement(request, pk): announcement = Announcement.objects.get(pk=pk) announcement.delete() messages.success(request, "Successfully deleted announcement!") - return redirect("electrika_announcements") - - -@login_required -@ensure_group_membership(group_names=["electrika_admin"]) -def download_csv_non_registrants(request): - import csv - from django.http import HttpResponse - - response = HttpResponse(content_type="text/csv") - response["Content-Disposition"] = 'attachment; filename="non_registrants.csv"' - - writer = csv.writer(response) - writer.writerow(["Name", "Email"]) - - users = User.objects.exclude( - email__in=ElectrikaUser.objects.values_list("user__email", flat=True) - ) - - users = users.exclude(is_staff=True) - users = users.exclude(is_superuser=True) - - for user in users: - writer.writerow([user, user.email]) - - return response - - -@login_required -@ensure_group_membership(group_names=["electrika_admin"]) -def team_download(request): - import csv - from django.http import HttpResponse - - response = HttpResponse(content_type="text/csv") - response["Content-Disposition"] = 'attachment; filename="teams.csv"' - - writer = csv.writer(response) - - queryset = Team.objects.select_related("team_leader__user").values( - "team_name", - "team_leader__user__first_name", - "team_leader__user__email", - "team_leader__user__phone_no", - ) - selected_fields = request.POST.getlist("selected_fields[]") - - # Write header row - header_row = selected_fields - writer.writerow(header_row) - - # Write data rows - for item in queryset: - row_data = [str(item[field]) for field in selected_fields] - - writer.writerow(row_data) - - return response + return redirect("electrika_announcements") \ No newline at end of file diff --git a/corpus/templates/electrika/home.html b/corpus/templates/electrika/home.html index c002a18e..ecc06128 100644 --- a/corpus/templates/electrika/home.html +++ b/corpus/templates/electrika/home.html @@ -283,7 +283,7 @@

SCHEDULE

Expert Talk
- + 6PM IST

@@ -330,7 +330,7 @@

SCHEDULE

-
Hardware Round
+
Hardware Round at NITK Campus

@@ -884,8 +884,8 @@

Contact Us

Apurva S : apurva.indumathi@gmail.com
- {% comment %} Raghuram Kannan : raghuramkannan400@gmail.com
- Kaliki Venkata Srinanda : srinandakv2004@gmail.com {% endcomment %} + Aditya Rajesh : adityacfal@gmail.com
+ Chandan G Padmashali : chandanpadmashalig125@gmail.com


From 187c459cb9ad934e26bf22952c5989aef0391ef0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 09:01:51 +0000 Subject: [PATCH 02/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- corpus/electrika/views.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/corpus/electrika/views.py b/corpus/electrika/views.py index 2a031e8f..36de1458 100644 --- a/corpus/electrika/views.py +++ b/corpus/electrika/views.py @@ -145,10 +145,10 @@ def index(request): @login_required @module_enabled(module_name="electrika") def register(request): - - next_param = request.GET.get('next', '/') - request.session['registration_next'] = next_param - + + next_param = request.GET.get("next", "/") + request.session["registration_next"] = next_param + config = ModuleConfiguration.objects.get(module_name="electrika").module_config reg_start_datetime, reg_end_datetime = ( @@ -505,4 +505,4 @@ def delete_announcement(request, pk): announcement = Announcement.objects.get(pk=pk) announcement.delete() messages.success(request, "Successfully deleted announcement!") - return redirect("electrika_announcements") \ No newline at end of file + return redirect("electrika_announcements") From 7d08a16fa5dbb58041aa7d914ec65f73dd4f4c68 Mon Sep 17 00:00:00 2001 From: Vignaraj-pai Date: Wed, 17 Jan 2024 14:39:23 +0530 Subject: [PATCH 03/12] Refactor register function in views.py --- corpus/electrika/views.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/corpus/electrika/views.py b/corpus/electrika/views.py index 2a031e8f..f1c01ec2 100644 --- a/corpus/electrika/views.py +++ b/corpus/electrika/views.py @@ -144,11 +144,7 @@ def index(request): @login_required @module_enabled(module_name="electrika") -def register(request): - - next_param = request.GET.get('next', '/') - request.session['registration_next'] = next_param - +def register(request): config = ModuleConfiguration.objects.get(module_name="electrika").module_config reg_start_datetime, reg_end_datetime = ( From b88cde1900271f1c33481e4ad9ebd5dd86af3082 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 09:10:31 +0000 Subject: [PATCH 04/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- corpus/electrika/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/corpus/electrika/views.py b/corpus/electrika/views.py index 9ce1a007..848edce5 100644 --- a/corpus/electrika/views.py +++ b/corpus/electrika/views.py @@ -144,7 +144,7 @@ def index(request): @login_required @module_enabled(module_name="electrika") -def register(request): +def register(request): config = ModuleConfiguration.objects.get(module_name="electrika").module_config reg_start_datetime, reg_end_datetime = ( From 3636dd22cbef7e56908c8cb6815411e95b36bba8 Mon Sep 17 00:00:00 2001 From: Vignaraj-pai Date: Wed, 17 Jan 2024 19:05:15 +0530 Subject: [PATCH 05/12] Update base.html and navbar_dropdown.html templates --- corpus/templates/base.html | 3 +-- corpus/templates/components/navbar_dropdown.html | 2 +- corpus/templates/electrika/index.html | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/corpus/templates/base.html b/corpus/templates/base.html index 41674877..f42816e4 100644 --- a/corpus/templates/base.html +++ b/corpus/templates/base.html @@ -37,8 +37,7 @@ margin: 0; padding: 0; font-family: 'Ubuntu', sans-serif; - } - + } diff --git a/corpus/templates/components/navbar_dropdown.html b/corpus/templates/components/navbar_dropdown.html index 61e0dbf1..764c2ae0 100644 --- a/corpus/templates/components/navbar_dropdown.html +++ b/corpus/templates/components/navbar_dropdown.html @@ -1,4 +1,4 @@ - From e78d3a62b1af976a894dd762e30beedf8d9d8b93 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 18:13:11 +0000 Subject: [PATCH 09/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- corpus/templates/electrika/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/corpus/templates/electrika/index.html b/corpus/templates/electrika/index.html index 3c17c22d..3a18ed8c 100644 --- a/corpus/templates/electrika/index.html +++ b/corpus/templates/electrika/index.html @@ -265,7 +265,7 @@

Send Invite

- For teams with more than one participant: + For teams with more than one participant:
Each member must create an account on Corpus.
From ac6e9cf070ed6973e98953908c3725e9a1c50029 Mon Sep 17 00:00:00 2001 From: Vignaraj-pai Date: Thu, 18 Jan 2024 14:15:02 +0530 Subject: [PATCH 10/12] Fix team creation logic and update FAQ section --- corpus/electrika/views.py | 17 +++++++---- corpus/templates/electrika/home.html | 44 ++++++++++++++++++++++----- corpus/templates/electrika/index.html | 6 ++-- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/corpus/electrika/views.py b/corpus/electrika/views.py index 5401c433..9da3aa5d 100644 --- a/corpus/electrika/views.py +++ b/corpus/electrika/views.py @@ -363,7 +363,7 @@ def team_page(request, pk): @ensure_group_membership(group_names=["electrika_admin"]) def create_team_admin(request): import random - + random.seed(datetime.now().second) electrika_users = ElectrikaUser.objects.filter(team=None, to_be_teamed_up=True) TEAM_NAMES = [ "Iconoclasts", @@ -389,6 +389,8 @@ def create_team_admin(request): num_users = electrika_users.count() num_teams = num_users // 4 + electrika_users = list(electrika_users) + if num_users == 0: messages.error(request, "Not enough users to create teams!") return redirect("electrika_admin_teams") @@ -397,11 +399,13 @@ def create_team_admin(request): with transaction.atomic(): for i in range(num_teams): team_name = TEAM_NAMES[random.randint(0, len(TEAM_NAMES) - 1)] - team = Team(team_name=team_name, team_leader=electrika_users[i * 4]) + team_leader_index = i * 4 + team_leader = electrika_users[team_leader_index] + team = Team(team_name=team_name, team_leader=team_leader) team.save() for j in range(4): index = i * 4 + j - if index >= electrika_users.count(): + if index >= len(electrika_users): break user = electrika_users[index] user.team = team @@ -409,14 +413,15 @@ def create_team_admin(request): user.save() if num_users % 4 != 0: - team_name = TEAM_NAMES[num_teams % len(TEAM_NAMES)] + team_name = TEAM_NAMES[random.randint(0, len(TEAM_NAMES) - 1)] + team_leader_index = num_teams * 4 team = Team( - team_name=team_name, team_leader=electrika_users[num_teams * 4] + team_name=team_name, team_leader=electrika_users[team_leader_index] ) team.save() for j in range(num_users % 4): index = num_teams * 4 + j - if index >= electrika_users.count(): + if index >= len(electrika_users): break user = electrika_users[num_teams * 4 + j] user.team = team diff --git a/corpus/templates/electrika/home.html b/corpus/templates/electrika/home.html index ecc06128..2cc5d82a 100644 --- a/corpus/templates/electrika/home.html +++ b/corpus/templates/electrika/home.html @@ -358,6 +358,7 @@

SCHEDULE

openFaq14: false, openFaq15: false, openFaq16: false, + openFaq17: false, } " class="bg-base-200 pt-20 pb-12 lg:pt-[120px] lg:pb-[90px]"> @@ -462,7 +463,7 @@

SCHEDULE

- Top 2 teams will receive cash prizes from a pool of Rs 5000. + Top 2 teams will receive prizes from a pool of Rs 5000.

@@ -483,7 +484,7 @@

SCHEDULE

- Is it necessary to be from EC or EEE background? + Is it necessary to be from ECE or EEE background?

@@ -588,12 +589,12 @@

SCHEDULE

> -
+

@@ -612,6 +613,35 @@

SCHEDULE

+
+ +
+

+ Yes, a food coupon will be provided for the canteen. +

+
+
+
@@ -639,7 +669,7 @@

SCHEDULE

- No. The test will have questions about the basics of Linear Algebra, Signals and Systems, Machine Learning, Aptitude and some Python coding. It will not have any competitive coding style questions. + No. The test will have questions about the basics of analog and power electronics , basic control systems and Aptitude. It will not have any competitive coding style questions.

@@ -813,7 +843,7 @@

SCHEDULE

- Yes, All teams qualifying round-1 will receive certificates. + All teams qualifying preliminary test will receive participation certificate.

diff --git a/corpus/templates/electrika/index.html b/corpus/templates/electrika/index.html index 3c17c22d..ff546e67 100644 --- a/corpus/templates/electrika/index.html +++ b/corpus/templates/electrika/index.html @@ -90,10 +90,10 @@

-
+ class="about bg-base-100 text-center prose px-1 sm:px-10 lg:px-40 py-10 min-w-full"> +
-
+
{% if in_team %} From b3840b9bb2b7a5bb1df4efb81e5c790b3b5708ee Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 08:46:22 +0000 Subject: [PATCH 11/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- corpus/electrika/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/corpus/electrika/views.py b/corpus/electrika/views.py index 9da3aa5d..4792541f 100644 --- a/corpus/electrika/views.py +++ b/corpus/electrika/views.py @@ -363,6 +363,7 @@ def team_page(request, pk): @ensure_group_membership(group_names=["electrika_admin"]) def create_team_admin(request): import random + random.seed(datetime.now().second) electrika_users = ElectrikaUser.objects.filter(team=None, to_be_teamed_up=True) TEAM_NAMES = [ From 778879bac56420d2373dbde755a5abd9b4e88cd2 Mon Sep 17 00:00:00 2001 From: Vignaraj-pai Date: Fri, 19 Jan 2024 13:36:42 +0530 Subject: [PATCH 12/12] Add phone number and team-up option to user table --- corpus/templates/electrika/admin/users.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/corpus/templates/electrika/admin/users.html b/corpus/templates/electrika/admin/users.html index ba29a522..851dfb73 100644 --- a/corpus/templates/electrika/admin/users.html +++ b/corpus/templates/electrika/admin/users.html @@ -31,11 +31,13 @@

Stats

S.No. Name Email + Phone Number From NITK? College Name IEEE Member? IEEE Membership Number In a Team? + Opted for getting teamed up? @@ -44,11 +46,13 @@

Stats

{{ forloop.counter }} {{ user.user }} {{ user.user.email }} + {{ user.user.phone_no }} {{ user.from_nitk|yesno:"Yes,No" }} {{ user.college_name }} {{ user.ieee_member|yesno:"Yes,No" }} {{ user.ieee_membership_no }} {{ user.team|yesno:"Yes,No" }} + {{ user.to_be_teamed_up|yesno:"Yes,No" }} {% endfor %}