basic UI!

main
eric 2023-03-02 17:40:34 -05:00
parent 04a1da355c
commit ca3c0e4fe5
4 changed files with 74 additions and 13 deletions

View File

@ -0,0 +1,27 @@
<html>
<head>
<title>DOAB Hosts</title>
</head>
<body>
<h2>
Linkchecking for
{{provider.provider}} ({{provider.link_count}})
</h2>
<ul>
{% for link in links %}
<li>
<a href="{{link.url}}">{{link.url}}</a>
<table>
{% for check in link.checks.all %}
<tr>
<td>{{ check.created }}</td>
<td {% if check.return_code != 200 %} style="color:red"{% endif %}>{{ check.return_code }}</td>
<td>{{check.content_type}}</td>
</tr>
{% endfor %}
</table>
</li>
{% endfor %}
</ul>
</body>
</html>

View File

@ -0,0 +1,12 @@
<html>
<head>
<title>DOAB Hosts</title>
</head>
<body>
<ul>
{% for provider in provider_list %}
<li><a href="{% url 'provider' provider.provider %}">{{provider.provider}}</a> ({{provider.link_count}})</li>
{% endfor %}
</ul>
</body>
</html>

View File

@ -1,21 +1,12 @@
"""doab_check URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from . import views
urlpatterns = [
path('admin/', admin.site.urls),
path('providers/', views.ProvidersView.as_view(), name='providers'),
path('providers/<str:provider>/', views.ProviderView.as_view(), name='provider'),
]

31
doab_check/views.py Normal file
View File

@ -0,0 +1,31 @@
"""doab_check views
"""
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from django.views import generic
from .models import Link
class ProvidersView(generic.TemplateView):
template_name = 'providers.html'
def get_context_data(self, **kwargs):
providers = Link.objects.order_by('provider').values('provider').distinct()
for provider in providers:
provider['link_count'] = Link.objects.filter(provider=provider['provider']).count()
return {'provider_list': providers}
class ProviderView(generic.TemplateView):
template_name = 'provider.html'
def get_context_data(self, **kwargs):
prov = kwargs['provider']
provider = {'provider': prov}
provider_links = Link.objects.filter(provider=prov)
provider['link_count'] = provider_links.count()
return {'provider': provider, 'links': provider_links}