Skip to content

Commit

Permalink
Fixed registration issue in Electrika. (#99)
Browse files Browse the repository at this point in the history
* Fixed registration issue in Electrika.
Info Update on Home page

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Refactor register function in views.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Vignaraj-pai and pre-commit-ci[bot] authored Jan 17, 2024
1 parent 9209022 commit 6aba616
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 66 deletions.
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

0 comments on commit 6aba616

Please sign in to comment.