Skip to content

Commit

Permalink
Merge branch 'urls-with-trailing-slashes' of github.com:ddabble/Hacke…
Browse files Browse the repository at this point in the history
…rspace-website into ddabble-urls-with-trailing-slashes

* 'urls-with-trailing-slashes' of github.com:ddabble/Hackerspace-website:
  Replaced hardcoded hrefs with URL lookups
  Made URLs end with a trailing slash
  Replaced hardcoded success URLs with lookups
  • Loading branch information
michaelbrusegard committed Apr 10, 2024
2 parents 880c25c + aa22ea0 commit ff174fb
Show file tree
Hide file tree
Showing 33 changed files with 93 additions and 87 deletions.
2 changes: 1 addition & 1 deletion applications/templates/applications/application_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% translate "Søknad" as trans_apply %}
{% includeslots "website/page_overview/content_title.html" with title=trans_apply %}
{% slot children %}
<a class="btn btn-flat hs-green-text white" href="/opptak/">{% trans "Tilbake til infoside" %}</a>
<a class="btn btn-flat hs-green-text white" href="{% url 'application:application_info' %}">{% trans "Tilbake til infoside" %}</a>
{% endslots %}
<div class="section">
<div class="container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h4>Søknad</h4>
<div class="col s12">
<h4>Din søknad er registrert!</h4>
<p>Du videresendes til forsiden om 10 sekunder.</p>
<a href="/" class="btn btn-small hs-green">Trykk her for å gå til forsiden</a>
<a href="{% url 'index' %}" class="btn btn-small hs-green">Trykk her for å gå til forsiden</a>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions applications/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

urlpatterns = [
path("", views.ApplicationInfoView.as_view(), name="application_info"),
path("application", views.ApplicationView.as_view(), name="application_form"),
path("application/", views.ApplicationView.as_view(), name="application_form"),
path(
"success",
"success/",
TemplateView.as_view(template_name="applications/application_success.html"),
name="application_success",
),
Expand Down
3 changes: 2 additions & 1 deletion applications/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.urls import reverse_lazy
from django.views.generic import ListView
from django.views.generic.edit import FormView

Expand Down Expand Up @@ -25,7 +26,7 @@ def get_context_data(self, **kwargs):
class ApplicationView(FormView):
template_name = "applications/application_form.html"
form_class = ApplicationForm
success_url = "/opptak/success"
success_url = reverse_lazy("application:application_success")

def form_valid(self, form):
form.save() # must save before sending email in order to access group choice priorities
Expand Down
2 changes: 1 addition & 1 deletion authentication/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
app_name = "auth"

urlpatterns = [
path("logout", LogoutView.as_view(), name="logout"),
path("logout/", LogoutView.as_view(), name="logout"),
]
2 changes: 1 addition & 1 deletion door/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

urlpatterns = [
path("", views.DoorView.as_view(), name="door_post"),
path("json", views.DoorJsonView.as_view(), name="get_json"),
path("json/", views.DoorJsonView.as_view(), name="get_json"),
]
4 changes: 2 additions & 2 deletions files/templates/files/_gallery_include.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<div class="row">
{% if form.thumbnail.value and form.thumbnail.value != "None" %}
<div id="thumb-preview" class="card small thumb-preview col s12" style="background-image: url('/files/image-view/{{ form.thumbnail.value }}'); background-repeat:no-repeat; background-size: cover;">
<div id="thumb-preview" class="card small thumb-preview col s12" style="background-image: url('{% url 'files:image-detail' form.thumbnail.value %}'); background-repeat:no-repeat; background-size: cover;">
{% else %}
<div id="thumb-preview" class="card small thumb-preview col s12" style="background-image: none; background-repeat:no-repeat; background-size:cover;">
{% endif %}
Expand All @@ -25,7 +25,7 @@
if(e.target.innerText === "{% trans 'VELG' %}") { // This is really funny to me
var selectedImgId = e.target.attributes.value.value;
thumbnail_input.value = selectedImgId;
thumb_preview.style.backgroundImage = "url('/files/image-view/" + selectedImgId;
thumb_preview.style.backgroundImage = `url('/files/image-view/${selectedImgId}/`;
M.toast({html: '{% trans "Bildet er valgt" %}'});
M.Modal.getInstance(thumbModal).close();
}
Expand Down
2 changes: 1 addition & 1 deletion files/templates/files/images-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h4 class="white-text">{% trans "Velg bilde" %}</h4>
<div class="col s12 hide-on-large-only">
<div class="invisible-divider-large"></div>
</div>
<a class="col s12 l5 push-l2 btn hs-yellow btn-small hs-gray-text" href="/files/images" target="_blank">{% trans "Administrer bilder" %}</a>
<a class="col s12 l5 push-l2 btn hs-yellow btn-small hs-gray-text" href="{% url 'files:images' %}" target="_blank">{% trans "Administrer bilder" %}</a>
</div>
</div>

Expand Down
6 changes: 4 additions & 2 deletions files/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
urlpatterns = [
path("images/", views.ImageListView.as_view(), name="images"),
path("image-upload/", views.imageUpload, name="image-upload"),
path("image-delete/<int:pk>", views.ImageDeleteView.as_view(), name="image-delete"),
path("image-view/<int:pk>", views.ImageView.as_view(), name="image-detail"),
path(
"image-delete/<int:pk>/", views.ImageDeleteView.as_view(), name="image-delete"
),
path("image-view/<int:pk>/", views.ImageView.as_view(), name="image-detail"),
]
3 changes: 2 additions & 1 deletion files/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.urls import reverse_lazy
from django.views.generic import DeleteView, ListView, View

from .forms import ImageForm
Expand All @@ -10,7 +11,7 @@

class ImageDeleteView(PermissionRequiredMixin, DeleteView):
model = Image
success_url = "/files/images"
success_url = reverse_lazy("files:images")
permission_required = "files.delete_image"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h5>{% trans "Bildegalleri" %}</h5>

{% if user.is_superuser %}
<div class="col s12 m4">
<a href="/admin">
<a href="{% url 'admin:index' %}">
<div class="card-panel center">
<i class="material-icons large black-text">engineering</i>
<h5>{% trans "Adminpanel" %}</h5>
Expand Down
10 changes: 5 additions & 5 deletions internalportal/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
urlpatterns = [
path("", views.InternalPortalView.as_view(), name="internalportal"),
path("applications/", views.ApplicationsView.as_view(), name="applications"),
path("applications/<int:pk>", views.ApplicationView.as_view(), name="application"),
path("applications/<int:pk>/", views.ApplicationView.as_view(), name="application"),
path(
"applications/delete/<int:pk>",
"applications/delete/<int:pk>/",
views.ApplicationRemoveView.as_view(),
name="delete_application",
),
path(
"applications/next-group/<int:pk>",
"applications/next-group/<int:pk>/",
views.ApplicationNextGroupView.as_view(),
name="next_group",
),
path(
"applications/<int:pk>/approve",
"applications/<int:pk>/approve/",
views.ApplicationApproveView.as_view(),
name="approve_application",
),
path(
"applications/<int:pk>/interview-email",
"applications/<int:pk>/interview-email/",
views.ApplicationInterviewEmailView.as_view(),
name="interview_email",
),
Expand Down
2 changes: 1 addition & 1 deletion internalportal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def get(self, request, *args, **kwargs):
class ApplicationRemoveView(UserPassesTestMixin, DeleteView):
model = Application
template_name = "internalportal/applications/application_confirm_delete.html"
success_url = "/internalportal/applications/"
success_url = reverse_lazy("internalportal:applications")

def test_func(self):
committee = get_commitee_with_leader(self.request.user)
Expand Down
30 changes: 16 additions & 14 deletions inventory/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,36 @@

urlpatterns = [
path("", InventoryListView.as_view(), name="inventory"),
path("item/<int:pk>", ItemDetailView.as_view(), name="item"),
path("new", ItemCreateView.as_view(), name="new"),
path("edit/<int:pk>", ItemUpdateView.as_view(), name="edit"),
path("delete/<int:pk>", ItemDeleteView.as_view(), name="delete"),
path("item/<int:pk>/", ItemDetailView.as_view(), name="item"),
path("new/", ItemCreateView.as_view(), name="new"),
path("edit/<int:pk>/", ItemUpdateView.as_view(), name="edit"),
path("delete/<int:pk>/", ItemDeleteView.as_view(), name="delete"),
path("loans/", ItemLoanListView.as_view(), name="loans"),
path("loans/<int:pk>", ItemLoanDetailView.as_view(), name="loan_application"),
path("loans/<int:pk>/", ItemLoanDetailView.as_view(), name="loan_application"),
path(
"loans/approve/<int:pk>",
"loans/approve/<int:pk>/",
ItemLoanApproveView.as_view(),
name="loan_approve",
),
path("loans/deny/<int:pk>", ItemLoanDeclineView.as_view(), name="loan_deny"),
path("loans/deny/<int:pk>/", ItemLoanDeclineView.as_view(), name="loan_deny"),
path(
"loans/returned/<int:pk>",
"loans/returned/<int:pk>/",
ItemLoanReturnedView.as_view(),
name="loan_returned",
),
path(
"loans/apply/<int:pk>",
"loans/apply/<int:pk>/",
ItemLoanApplicationView.as_view(),
name="loan_apply",
),
path("equipment", EquipmentListView.as_view(), name="equipment"),
path("equipment/item/<int:pk>", EquipmentView.as_view(), name="equipment_detail"),
path("equipment/new", EquipmentCreateView.as_view(), name="equipment_new"),
path("equipment/edit/<int:pk>", EquipmentEditView.as_view(), name="equipment_edit"),
path("equipment/", EquipmentListView.as_view(), name="equipment"),
path("equipment/item/<int:pk>/", EquipmentView.as_view(), name="equipment_detail"),
path("equipment/new/", EquipmentCreateView.as_view(), name="equipment_new"),
path(
"equipment/delete/<int:pk>",
"equipment/edit/<int:pk>/", EquipmentEditView.as_view(), name="equipment_edit"
),
path(
"equipment/delete/<int:pk>/",
EquipmentDeleteView.as_view(),
name="equipment_delete",
),
Expand Down
6 changes: 3 additions & 3 deletions news/event_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
path("<int:pk>/edit/", views.EventUpdateView.as_view(), name="edit"),
path("<int:pk>/attended/", views.EventAttendeeEditView.as_view(), name="attended"),
path("<int:pk>/skills/", views.EventAttendeeSkillsView.as_view(), name="skills"),
path("new", views.EventCreateView.as_view(), name="new"),
path("new/", views.EventCreateView.as_view(), name="new"),
path("<int:pk>/delete/", views.EventDeleteView.as_view(), name="delete"),
path("<int:event_id>/register/", views.register_on_event, name="register"),
path("feed.ics", HSEventFeed()),
path("<int:pk>/feed.ics", HSEventSingleFeed()),
path("feed.ics", HSEventFeed(), name="feed"),
path("<int:pk>/feed.ics", HSEventSingleFeed(), name="single_feed"),
]
14 changes: 7 additions & 7 deletions news/templates/news/_event_admin_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ <h5>{% trans "Administrator-meny" %}</h5>
<div class="row">
<div class="col s12">
<ul class='collection'>
{% if event_admin_perm %}
<li class="collection-item"><a href="/events/{{ event.id }}/edit">
{% if perms.news.change_event %}
<li class="collection-item"><a href="{% url 'events:edit' event.id %}">
<i class="material-icons">edit</i>
<span class="collection-icon-text">{% trans "Rediger arrangement" %}</span></a>
</li>
{% endif %}
{% if event.registration and event_admin_perm %}
<li class="collection-item"><a href="/events/{{ event.id }}/attended">
{% if event.registration and user in event.responsibles %}
<li class="collection-item"><a href="{% url 'events:attended' event.id %}">
<i class="material-icons">check</i>
<span class="collection-icon-text">{% trans "Registrer oppmøte" %}</span>
</a></li>
{% endif %}
{% if event.skills.all and event_admin_perm %}
<li class="collection-item">
<a href="/events/{{ event.id }}/skills">
<a href="{% url 'events:skills' event.id %}">
<i class="material-icons">how_to_reg</i>
<span class="collection-icon-text">{% trans "Gi ferdigheter" %}</span>
</a>
</li>
{% endif %}
{% if perms.news.delete_event and event_admin_perm %}
<li class="collection-item"><a href="/events/{{ event.id }}/delete" class="modal-trigger hs-red-text">
<li class="collection-item"><a href="{% url 'events:delete' event.id %}" class="modal-trigger hs-red-text">
<i class="material-icons">delete</i>
<span class="collection-icon-text">{% trans "Slett arrangement" %}</span></a>
</li>
Expand Down Expand Up @@ -62,7 +62,7 @@ <h5>{% trans "Alle påmeldte" %}</h5>
<a class="event-attendee-name" href="{% url 'userprofile:profile_by_id' user.user.id %}">
{{ user.user.get_full_name }}
</a>
<a class="event-attendee-icon" href="/events/{{ event.id }}/attended">
<a class="event-attendee-icon" href="{% url 'events:attended' event.id %}">
{% if event.is_past_start %}
{% if user.attended %}
<span class="secondary-content tooltipped" data-position="top" data-tooltip="{% trans "Oppmøte registrert!" %}">
Expand Down
2 changes: 1 addition & 1 deletion news/templates/news/event.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ <h3 class="hide-on-small-only">{{ event.title }}</h3>
{{ event.formatted_markdown|safe }}
{% endautoescape %}
<div class="divider"></div>
<p><a href="feed.ics">
<p><a href="{% url 'events:feed' %}">
<button class="btn btn-flat white-text waves-effect waves-light hs-green"><i class="material-icons small">event_note</i> {% trans 'Last ned ICS-fil' %}</button>
</a></p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion news/templates/news/event_confirm_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h3>{% trans "Confirm Action" %}</h3>
<input class="btn btn-large hs-red" type="submit" value="{% trans "YES" %}" />
</form>
<br><br>
<a href="/news/" class="btn btn-large hs-green">{% trans "NO, GO BACK" %}</a>
<a href="{% url 'news:all' %}" class="btn btn-large hs-green">{% trans "NO, GO BACK" %}</a>
</div>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions news/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
app_name = "news"
urlpatterns = [
path("", views.ArticleListView.as_view(), name="all"),
path("<int:pk>", views.ArticleView.as_view(), name="details"),
path("<int:pk>/edit", views.ArticleUpdateView.as_view(), name="edit"),
path("new", views.ArticleCreateView.as_view(), name="new"),
path("<int:pk>/delete", views.ArticleDeleteView.as_view(), name="delete"),
path("<int:pk>/", views.ArticleView.as_view(), name="details"),
path("<int:pk>/edit/", views.ArticleUpdateView.as_view(), name="edit"),
path("new/", views.ArticleCreateView.as_view(), name="new"),
path("<int:pk>/delete/", views.ArticleDeleteView.as_view(), name="delete"),
]
8 changes: 4 additions & 4 deletions news/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect
from django.template.loader import render_to_string
from django.urls import reverse
from django.urls import reverse, reverse_lazy
from django.utils import timezone
from django.views.generic import (
CreateView,
Expand Down Expand Up @@ -377,7 +377,7 @@ class EventCreateView(PermissionRequiredMixin, SuccessMessageMixin, CreateView):
model = Event
template_name = "news/edit_event.html"
form_class = EventForm
success_url = "/events/"
success_url = reverse_lazy("events:all")
permission_required = "news.add_event"

def get_success_message(self, cleaned_data):
Expand Down Expand Up @@ -484,13 +484,13 @@ def get_success_url(self):

class ArticleDeleteView(PermissionRequiredMixin, DeleteView):
model = Article
success_url = "/news/"
success_url = reverse_lazy("news:all")
permission_required = "news.delete_article"


class EventDeleteView(PermissionRequiredMixin, DeleteView):
model = Event
success_url = "/events/"
success_url = reverse_lazy("events:all")
permission_required = "news.delete_event"


Expand Down
10 changes: 5 additions & 5 deletions projectarchive/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

app_name = "projectarchive"
urlpatterns = [
path(r"", views.ArticleListView.as_view(), name="Article_List"),
path("<int:pk>", views.ArticleView.as_view(), name="details"),
path(r"new", views.ArticleCreateView.as_view(), name="Article_Create"),
path("<int:pk>/edit", views.ArticleUpdateView.as_view(), name="edit"),
path("<int:pk>/delete", views.ArticleDeleteView.as_view(), name="delete"),
path("", views.ArticleListView.as_view(), name="Article_List"),
path("<int:pk>/", views.ArticleView.as_view(), name="details"),
path("new/", views.ArticleCreateView.as_view(), name="Article_Create"),
path("<int:pk>/edit/", views.ArticleUpdateView.as_view(), name="edit"),
path("<int:pk>/delete/", views.ArticleDeleteView.as_view(), name="delete"),
]
4 changes: 2 additions & 2 deletions projectarchive/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.contrib.messages.views import SuccessMessageMixin
from django.shortcuts import redirect
from django.urls import reverse
from django.urls import reverse, reverse_lazy
from django.views.generic import (
CreateView,
DeleteView,
Expand Down Expand Up @@ -98,5 +98,5 @@ def get_success_url(self):

class ArticleDeleteView(PermissionRequiredMixin, DeleteView):
model = Projectarticle
success_url = "/projectarchive/"
success_url = reverse_lazy("projectarchive:Article_List")
permission_required = "projectarchive.delete_projectarticle"
2 changes: 1 addition & 1 deletion reservations/templates/reservations/queue_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<h4>Viktig informasjon</h4>
{% if printer_rule %}
<blockquote>
{% trans "Les" %} <a href="/rules/{{printer_rule.id}}">{% trans "regler for bruk av 3D-printer" %}</a> {% trans "før du starter" %}.
{% trans "Les" %} <a href="{% url 'rule_details' printer_rule.id %}">{% trans "regler for bruk av 3D-printer" %}</a> {% trans "før du starter" %}.
</blockquote>
{% endif %}
<blockquote>{% trans "Ved å benytte reservasjonssystemet vårt setter vi av våre ressurser (både printer og folk på vakt som følger med). Det er derfor forventet at du møter opp tidsnok (gjerne 5 minutter før avsatt tid) og ikke går over tiden du har booket" %}.
Expand Down
2 changes: 1 addition & 1 deletion reservations/templates/reservations/reservation_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h4>Ny reservasjon</h4>
<label for="ex_comment">Kommentar</label>
</div>
{% if printer_rule %}
<span>Husk å lese <a href="/rules/{{printer_rule.id}}">regler for bruk av 3D-printer</a> før du starter.</span>
<span>Husk å lese <a href="{% url 'rule_details' printer_rule.id %}">regler for bruk av 3D-printer</a> før du starter.</span>
{% endif %}
</div>
<div class="modal-footer">
Expand Down
Loading

0 comments on commit ff174fb

Please sign in to comment.