Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed registration issue in Electrika. #99

Merged
merged 5 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions corpus/electrika/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
]
59 changes: 2 additions & 57 deletions corpus/electrika/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -500,60 +502,3 @@ def delete_announcement(request, 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
8 changes: 4 additions & 4 deletions corpus/templates/electrika/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ <h3 class="title text-xl md:text-2xl lg:text-3xl font-extrabold ">SCHEDULE</h3>
<div class="timeline-start md:text-end mb-10">
<time class="font-mono italic">23<sup>rd</sup> Jan, 2024</time>
<div class="text-md md:text-lg lg:text-xl font-black">Expert Talk</div>

6PM IST
</div>
<hr/>
</li>
Expand Down Expand Up @@ -330,7 +330,7 @@ <h3 class="title text-xl md:text-2xl lg:text-3xl font-extrabold ">SCHEDULE</h3>
</div>
<div class="timeline-start mb-10">
<time class="font-mono italic">3<sup>rd</sup> Feb, 2024</time>
<div class="text-lg font-black">Hardware Round</div>
<div class="text-lg font-black">Hardware Round at <span class="text-primary sm:text-lg md:text-xl lg:text-2xl">NITK Campus</span></div>

</div>
<hr />
Expand Down Expand Up @@ -884,8 +884,8 @@ <h3 class="title text-xl md:text-2xl lg:text-3xl font-extrabold">Contact Us</h3>
<center>
<p class="section-description text-md md:text-lg lg:text-xl">
<strong>Apurva S</strong> : <a href="mailto:[email protected]">[email protected]</a><br>
{% comment %} <strong>Raghuram Kannan</strong> : <a href="mailto:raghuramkannan400@gmail.com"> raghuramkannan400@gmail.com</a><br>
<strong>Kaliki Venkata Srinanda</strong> : <a href="mailto:srinandakv2004@gmail.com"> srinandakv2004@gmail.com</a> {% endcomment %}
<strong>Aditya Rajesh</strong> : <a href="mailto:adityacfal@gmail.com">adityacfal@gmail.com</a><br>
<strong>Chandan G Padmashali</strong> : <a href="mailto:chandanpadmashalig125@gmail.com">chandanpadmashalig125@gmail.com</a>
</p>
</center>
<br>
Expand Down