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 - Embedathon

-

{{ 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 - Impulse

-

{{ announcement.content }}

+
+ {{ announcement.content | linebreaks }} +
{% if announcement.url_link %}

{{ 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 @@

Prizes

+
+

Workshops

+
+
+
+

Image Processing using OpenCV

+ 10th Jan, 2024 at 6:30PM + +
+
+
+
+

Introduction to Embedded Systems

+ 15th Jan, 2024 at 6:30PM + +
+
+
+
+

Speakers

@@ -63,6 +91,10 @@

Light Weight Cryptography for IoT

Session Link + + Session Resources +
@@ -81,6 +113,10 @@

Design and Validation of Hybrid Systems

Session Link + + Session Resources + diff --git a/corpus/templates/embedathon/index.html b/corpus/templates/embedathon/index.html index 0ad2b47e..793dad76 100644 --- a/corpus/templates/embedathon/index.html +++ b/corpus/templates/embedathon/index.html @@ -167,7 +167,7 @@

Announcements

diff --git a/corpus/templates/impulse/index.html b/corpus/templates/impulse/index.html index 7bbe2e2c..1a2e871e 100644 --- a/corpus/templates/impulse/index.html +++ b/corpus/templates/impulse/index.html @@ -214,6 +214,17 @@

Send Invite

{% endif %} {% elif registration_active %} + {% comment %} IMPORTANT DANGER BANNER {% endcomment %} +
+ + + + + YOU ARE NOT IN A TEAM. Please create a team or join an existing team to complete your registration for Impulse. + +

Current Invites

{% if invites_for_user %} @@ -286,7 +297,7 @@

Announcements