diff --git a/corpus/embedathon/views.py b/corpus/embedathon/views.py index a799c35c..6030da6e 100644 --- a/corpus/embedathon/views.py +++ b/corpus/embedathon/views.py @@ -5,6 +5,7 @@ from config.models import ModuleConfiguration from django.contrib import messages from django.contrib.auth.decorators import login_required +from django.db.models import Count from django.shortcuts import redirect from django.shortcuts import render from embedathon.forms import AnnouncementForm @@ -263,7 +264,8 @@ def admin(request): @ensure_group_membership(group_names=["embedathon_admin"]) def team_management(request): teams = Team.objects.all() - args = {"teams": teams} + team_counts = teams.values("payment_status").annotate(count=Count("payment_status")) + args = {"teams": teams, "team_counts": team_counts} return render(request, "embedathon/team_management.html", args) @@ -294,7 +296,18 @@ def mark_payment_complete(request, pk): def user_management(request): users = EmbedathonUser.objects.all() - args = {"users": users} + nitk_count = users.values("from_nitk").annotate(count=Count("from_nitk")) + ieee_count = users.values("ieee_member").annotate(count=Count("ieee_member")) + cass_count = users.values("cass_member").annotate(count=Count("cass_member")) + years_count = users.values("year").annotate(count=Count("year")) + + args = { + "users": users, + "nitk_count": nitk_count, + "ieee_count": ieee_count, + "cass_count": cass_count, + "years_count": years_count, + } return render(request, "embedathon/user_management.html", args) diff --git a/corpus/impulse/migrations/0003_alter_announcement_announcement_type.py b/corpus/impulse/migrations/0003_alter_announcement_announcement_type.py new file mode 100644 index 00000000..3c106ba1 --- /dev/null +++ b/corpus/impulse/migrations/0003_alter_announcement_announcement_type.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-01-06 18:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('impulse', '0002_remove_team_payment_proof'), + ] + + operations = [ + migrations.AlterField( + model_name='announcement', + name='announcement_type', + field=models.CharField(choices=[('A', 'All Impulse Users'), ('P', 'Paid Teams'), ('U', 'Unpaid Teams'), ('N', 'Registered for Impulse but no team'), ('NI', 'Not Registered for Impulse')], default='A', max_length=2), + ), + ] diff --git a/corpus/impulse/models.py b/corpus/impulse/models.py index 8b9bd0b5..8fd62f16 100644 --- a/corpus/impulse/models.py +++ b/corpus/impulse/models.py @@ -34,16 +34,17 @@ def __str__(self): class Announcement(models.Model): AnnouncementType = ( - ("A", "All"), + ("A", "All Impulse Users"), ("P", "Paid Teams"), ("U", "Unpaid Teams"), - ("N", "Not Registered Teams"), + ("N", "Registered for Impulse but no team"), + ("NI", "Not Registered for Impulse"), ) content = models.TextField(blank=False, null=False) url_link = models.URLField(blank=True, null=True) url_link_text = models.CharField(max_length=200, blank=True, null=True) - announcement_type = models.CharField(max_length=1, choices=AnnouncementType, blank=False, null=False, default="A") + announcement_type = models.CharField(max_length=2, choices=AnnouncementType, blank=False, null=False, default="A") date_created = models.DateTimeField(auto_now_add=True) date_modified = models.DateTimeField(auto_now=True) diff --git a/corpus/impulse/urls.py b/corpus/impulse/urls.py index 98bf1ccf..bdfb9434 100644 --- a/corpus/impulse/urls.py +++ b/corpus/impulse/urls.py @@ -38,4 +38,10 @@ views.delete_announcement, name="impulse_delete_announcement", ), + path( + "admin/download_csv", + views.download_csv_non_registrants, + name="impulse_download_csv", + ), + ] \ No newline at end of file diff --git a/corpus/impulse/views.py b/corpus/impulse/views.py index 3c789d8f..666b6c99 100644 --- a/corpus/impulse/views.py +++ b/corpus/impulse/views.py @@ -403,6 +403,24 @@ def announcements_management(request): "user__email", flat=True ) ) + elif announcement.announcement_type == "NI": + # all users who have not registered for impulse + users = User.objects.exclude( + email__in=ImpulseUser.objects.values_list("user__email", flat=True) + ) + + users = users.exclude( + email__in=[ + "impulse_admin", + "embedathon_admin", + ] + ) + users = users.exclude(is_staff=True) + users = users.exclude(is_superuser=True) + + email_ids = list(users.values_list("email", flat=True)) + + if email_ids is not None: send_email( "Announcement | Impulse", @@ -463,4 +481,36 @@ def mark_payment_incomplete(request, pk): bcc=[member.user.email], ) messages.success(request, "Successfully marked payment as incomplete!") - return redirect("impulse_admin_team_page", pk=pk) \ No newline at end of file + return redirect("impulse_admin_team_page", pk=pk) + + +@login_required +@ensure_group_membership(group_names=["impulse_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=ImpulseUser.objects.values_list("user__email", flat=True) + ) + + users = users.exclude( + email__in=[ + "impulse_admin", + "embedathon_admin", + ] + ) + users = users.exclude(is_staff=True) + users = users.exclude(is_superuser=True) + + + for user in users: + writer.writerow([user, user.email]) + + return response \ No newline at end of file diff --git a/corpus/templates/emails/embedathon/announcement.html b/corpus/templates/emails/embedathon/announcement.html index f5a6d04f..fc0e5cd2 100644 --- a/corpus/templates/emails/embedathon/announcement.html +++ b/corpus/templates/emails/embedathon/announcement.html @@ -6,7 +6,7 @@ {% block content %}
{{ announcement.content }}
+{{ announcement.content | linebreaks }}
{% if announcement.url_link %}{{ announcement.url_link_text }} diff --git a/corpus/templates/emails/impulse/announcement.html b/corpus/templates/emails/impulse/announcement.html index d272b6a7..e2924c44 100644 --- a/corpus/templates/emails/impulse/announcement.html +++ b/corpus/templates/emails/impulse/announcement.html @@ -6,7 +6,9 @@ {% block content %}
{{ announcement.content }}
+{{ announcement.url_link_text }} diff --git a/corpus/templates/embedathon/home.html b/corpus/templates/embedathon/home.html index 8144fc21..b70feb71 100644 --- a/corpus/templates/embedathon/home.html +++ b/corpus/templates/embedathon/home.html @@ -46,6 +46,34 @@
Number of teams: {{ teams.count }}
+{{ item.payment_status }}:{{ item.count }}
+ {% endfor %} +where E = Exempt, P = Paid, U = Unpaid.
+24-Hour Signal Processing Hackathon
+Theme: Explainable AI
NATIONAL INSTITUTE OF TECHNOLOGY KARNATAKA
10th - 13th January 2024
- {% if registration_active %} - Register - {% elif registration_done %} + {% if registration_active and not registration_done and not registered %} + Register Now + {% elif registration_done and not registered %} Registerations Closed {% elif registered %} - Registered, Go to Dashboard + Go to Dashboard {% else %} Registerations Opening Soon {% endif %} @@ -241,7 +242,7 @@+ After registering for Impulse, make sure to create a team name irrespective of you taking part alone or in teams of 2. After creating the team, join the discord link to receive updates and announcements regarding the event. +
+@@ -382,12 +413,12 @@
@@ -405,6 +436,36 @@
+ Final hackathon is in hybrid (both offline and online) mode, teams need not come to NITK campus for final hackathon . If you choose to come to campus, travel and accommodation will not be arranged. Students have to make the travel and accommodation arrangements themselves. Lunch will be provided on 14th January. +
+@@ -442,12 +503,12 @@
@@ -471,12 +532,12 @@
@@ -500,12 +561,12 @@
@@ -523,6 +584,36 @@
+ The final hackathon will be held for 24 hours from 13th January afternoon to 14th January afternoon. Only those who clear the preliminary test would be eligible for the same. +
+