Browse Source

add partial lists

main
xenua 2 years ago
parent
commit
21e0e451f7
Signed by: xenua
GPG Key ID: 8F93B68BD37255B8
  1. 19
      leftists/templates/interface/linkedlist.html
  2. 2
      leftists/templates/interface/overview.html
  3. 3
      leftists/urls.py
  4. 15
      leftists/views.py

19
leftists/templates/interface/linkedlist.html

@ -0,0 +1,19 @@
{% extends "base.html" %}
{% block main %}
<table>
<tr>
<th></th>
<th>link</th>
<th>to</th>
</tr>
{% for link in object_list %}
<tr>
<td><code><a href="{% url 'interface.link.update' link.slug %}">[e]</a> | <a href="{% url 'interface.link.delete' link.slug %}">[d]</a></code></td>
<td>{{ link.link }}</td>
<td>{{ link.to }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}

2
leftists/templates/interface/overview.html

@ -5,7 +5,7 @@
managing these domains: managing these domains:
<ul> <ul>
{% for domain in domains %} {% for domain in domains %}
<li>{{ domain.fqdn }}</li> <li><a href="{% url 'interface.link.list' domain.fqdn %}">{{ domain.fqdn }}</a></li>
{% endfor %} {% endfor %}
<table> <table>

3
leftists/urls.py

@ -1,7 +1,7 @@
from django.urls import path from django.urls import path
from leftists.views import ShortLinkRedirectView, CoolerLoginView, OverView, LinkCreateView, LinkUpdateView, \ from leftists.views import ShortLinkRedirectView, CoolerLoginView, OverView, LinkCreateView, LinkUpdateView, \
LinkDeleteView LinkDeleteView, LinkListView
urlpatterns = [ urlpatterns = [
path('', CoolerLoginView.as_view(), name='login'), path('', CoolerLoginView.as_view(), name='login'),
@ -9,5 +9,6 @@ urlpatterns = [
path('iface/link/create', LinkCreateView.as_view(), name='interface.link.create'), path('iface/link/create', LinkCreateView.as_view(), name='interface.link.create'),
path('iface/link/update/<str:slug>', LinkUpdateView.as_view(), name='interface.link.update'), path('iface/link/update/<str:slug>', LinkUpdateView.as_view(), name='interface.link.update'),
path('iface/link/delete/<str:slug>', LinkDeleteView.as_view(), name='interface.link.delete'), path('iface/link/delete/<str:slug>', LinkDeleteView.as_view(), name='interface.link.delete'),
path('iface/<str:domain>/links', LinkListView.as_view(), name='interface.link.list'),
path('<str:link>', ShortLinkRedirectView.as_view(), name='link-redirect'), path('<str:link>', ShortLinkRedirectView.as_view(), name='link-redirect'),
] ]

15
leftists/views.py

@ -2,8 +2,8 @@ from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.views import LoginView from django.contrib.auth.views import LoginView
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.views.generic import RedirectView, TemplateView, CreateView, UpdateView, DeleteView from django.views.generic import RedirectView, TemplateView, CreateView, UpdateView, DeleteView, ListView
from django_scopes import scopes_disabled from django_scopes import scopes_disabled, scope
from scopedsites.models import Domain from scopedsites.models import Domain
from leftists.forms import LinkForm from leftists.forms import LinkForm
@ -37,6 +37,17 @@ class OverView(LoginRequiredMixin, TemplateView):
return ctx return ctx
class LinkListView(LoginRequiredMixin, ListView):
template_name = 'interface/linkedlist.html'
model = ShortLink
def get(self, request, *args, **kwargs):
with scopes_disabled():
d = Domain.objects.get(fqdn__contains=kwargs.get('domain'))
with scope(domain=d):
return super().get(request, *args, **kwargs)
class LinkCreateView(LoginRequiredMixin, CreateView): class LinkCreateView(LoginRequiredMixin, CreateView):
template_name = 'interface/basic_form.html' template_name = 'interface/basic_form.html'
model = ShortLink model = ShortLink

Loading…
Cancel
Save