Skip to content

Commit

Permalink
backout of commit cd6f990
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikhorluck committed Aug 3, 2024
1 parent 89674ac commit 0755e56
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 80 deletions.
5 changes: 0 additions & 5 deletions apps/approval/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
views.create_membership_application,
name="approval_send_membership_application",
),
re_path(
r"^update_user_name/$",
views.update_user_name,
name="update_user_name",
),
re_path(
r"^cancel_application/(?P<application_id>\d+)/$",
views.cancel_application,
Expand Down
43 changes: 10 additions & 33 deletions apps/approval/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
@login_required
def create_fos_application(request):
if request.method == "POST":
# if not request.user.ntnu_username:
# messages.error(
# request, _("Du må knytte et NTNU-brukernavn til kontoen din.")
# )
# return redirect("profiles_active", active_tab="membership")
if not request.user.ntnu_username:
messages.error(
request, _("Du må knytte et NTNU-brukernavn til kontoen din.")
)
return redirect("profiles_active", active_tab="membership")

form = FieldOfStudyApplicationForm(request.POST, request.FILES)
if form.is_valid():
Expand Down Expand Up @@ -79,9 +79,6 @@ def create_fos_application(request):

messages.success(request, _("Søknad om bytte av studieretning er sendt."))

else:
messages.error(request, str(form.errors))

return redirect("profiles_active", active_tab="membership")
raise Http404

Expand Down Expand Up @@ -111,11 +108,11 @@ def create_membership_application(request):
messages.error(request, _("Din bruker har ikke et utløpende medlemskap."))
return redirect("profiles_active", active_tab="membership")

# if not request.user.ntnu_username:
# messages.error(
# request, _("Du må knytte et NTNU-brukernavn til kontoen din.")
# )
# return redirect("profiles_active", active_tab="membership")
if not request.user.ntnu_username:
messages.error(
request, _("Du må knytte et NTNU-brukernavn til kontoen din.")
)
return redirect("profiles_active", active_tab="membership")

# Grant membership until 16th of September this year if the request was sent previous to 1st of July,
# or until 16th of September next year if the request was sent after 1st of July
Expand All @@ -139,26 +136,6 @@ def create_membership_application(request):
raise Http404


@login_required
def update_user_name(request):
if request.method == "POST":
first_name = request.POST.get("first_name")
last_name = request.POST.get("last_name")

if not first_name or not last_name:
messages.error(request, _("Både fornavn og etternavn må fylles ut."))
return redirect("profiles_active", active_tab="membership")

# Update the user's first and last name
request.user.first_name = first_name
request.user.last_name = last_name
request.user.save()

messages.success(request, _("Ditt navn har blitt oppdatert."))
return redirect("profiles_active", active_tab="membership")
raise Http404


@login_required
def cancel_application(request, application_id):
app = get_object_or_404(MembershipApproval, pk=application_id)
Expand Down
65 changes: 23 additions & 42 deletions templates/profiles/membership.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
{% load crispy_forms_tags %}


<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4">
<h3>Medlemskap</h3>
</div>
</div>

{% if not user.first_name or not user.last_name %}
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-5">
<form id="user-name-form" method="post" action="{% url 'update_user_name' %}">
{% csrf_token %}
<h3>Vi trenger ditt fornavn og etternavn!</h3>
<div class="form-group">
<label for="first_name">Fornavn</label>
<input type="text" class="form-control" id="first_name" name="first_name" required>
</div>
<div class="form-group">
<label for="last_name">Etternavn</label>
<input type="text" class="form-control" id="last_name" name="last_name" required>
</div>
<button type="submit" class="btn btn-primary">Send inn</button>
</form>
</div>
</div>
<hr />
{% else %}




<div class="row">
<div class="col-xs-12 membership-text">
Her kan du administrere dine søknader for medlemskap i Online, Linjeforeningen for Informatikk! <br>
Expand Down Expand Up @@ -66,22 +40,23 @@ <h3>Vi trenger ditt fornavn og etternavn!</h3>
</div>
</div>
<div class="manual-membership-form">
{% if user.has_expiring_membership %}
<hr />
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6">
<p class="ingress">
Ettersom du har et gammelt medlemskap kan du søke om å få dette forlenget. Forlengelsen er for ett år om gangen.
</p>
</div>
<div class="col-xs-12 col-sm-6 col-md-3">
<form id="membership-application" method="post" action="{% url 'approval_send_membership_application' %}">
{% csrf_token %}
<button type="submit" class="btn btn-success pull-right">Send søknad om forlengelse</button>
</form>
{% if user.ntnu_username %}
{% if user.has_expiring_membership %}
<hr />
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6">
<p class="ingress">
Ettersom du har et gammelt medlemskap kan du søke om å få dette forlenget. Forlengelsen er for ett år om gangen.
</p>
</div>
<div class="col-xs-12 col-sm-6 col-md-3">
<form id="membership-application" method="post" action="{% url 'approval_send_membership_application' %}">
{% csrf_token %}
<button type="submit" class="btn btn-success pull-right">Send søknad om forlengelse</button>
</form>
</div>
</div>
</div>
{% else %}
{% endif %}
<hr />
<div class="row">
<div class="col-md-12">
Expand Down Expand Up @@ -120,6 +95,13 @@ <h3>Vi trenger ditt fornavn og etternavn!</h3>
</form>
</div>
</div>
{% else %}
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4">
<p>For å aktivere ditt medlemskap kreves det at du har knyttet din studentkonto til din profil.</p>
<p>Gå til Epost-innstillinger og registrer din @stud.ntnu.no epost.</p>
</div>
</div>
{% endif %}
</div>
{% endif %}
Expand Down Expand Up @@ -207,4 +189,3 @@ <h5>{{ heading|capfirst }}</h5>
</div>
</div>
</div>
{% endif %}

0 comments on commit 0755e56

Please sign in to comment.