add publisher reports
parent
a1a09dfb01
commit
e8314f4fa7
|
@ -21,6 +21,10 @@ class Item(models.Model):
|
|||
def __str__(self):
|
||||
return self.doab.split('/')[1] if '/' in self.doab else self.doab
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
return f'https://directory.doabooks.org/handle/{self.doab}'
|
||||
|
||||
class Link(models.Model):
|
||||
''' these are the links we're going to check '''
|
||||
url = models.URLField(max_length=1024, unique=True)
|
||||
|
|
|
@ -24,6 +24,9 @@ When a link is checked we record the status code returned by the web server. "40
|
|||
<li>
|
||||
View <a href="{% url 'providers' %}">the list of host names we've checked</a>.
|
||||
</li>
|
||||
<li>
|
||||
View <a href="{% url 'publishers' %}">the list of publishers whose links we've checked</a>.
|
||||
</li>
|
||||
</ul>
|
||||
We'll be adding more views of the link checking data as the project develops.
|
||||
</body>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>DOAB Link Checking for {{ publisher.publisher }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>
|
||||
DOAB Linkchecking for
|
||||
{{ publisher.publisher }} ({{ items.count }} records)
|
||||
</h2>
|
||||
<ul>
|
||||
{% for item in items %}
|
||||
<li>
|
||||
<a href="{{ item.url }}">{{ item.doab }}</a> - {{ item.title }}
|
||||
{% for link in item.links.all %}
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<a href="{{ link.url }}">{{ link.url }}</a>
|
||||
</th>
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
{% for check in link.checks.all %}
|
||||
<tr {% if check.return_code != 200 %} style="color:red"{% endif %}>
|
||||
<td>{{ check.created }}</td>
|
||||
<td>{{ check.return_code }}</td>
|
||||
<td>{{ check.content_type }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,15 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>DOAB Publishers</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>
|
||||
DOAB Linkchecking by Publisher
|
||||
</h2>
|
||||
<ul>
|
||||
{% for publisher in publisher_list %}
|
||||
<li><a href="{% url 'publisher' publisher.publisher_name %}">{{publisher.publisher_name}}</a> ({{publisher.item_count}})</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -11,4 +11,6 @@ urlpatterns = [
|
|||
path('admin/', admin.site.urls),
|
||||
path('providers/', views.ProvidersView.as_view(), name='providers'),
|
||||
path('providers/<str:provider>/', views.ProviderView.as_view(), name='provider'),
|
||||
path('publishers/', views.PublishersView.as_view(), name='publishers'),
|
||||
path('publishers/<str:publisher>/', views.PublisherView.as_view(), name='publisher'),
|
||||
]
|
||||
|
|
|
@ -6,7 +6,7 @@ from django.shortcuts import get_object_or_404, render
|
|||
from django.urls import reverse
|
||||
from django.views import generic
|
||||
|
||||
from .models import Link
|
||||
from .models import Item, Link
|
||||
|
||||
|
||||
class ProvidersView(generic.TemplateView):
|
||||
|
@ -29,3 +29,24 @@ class ProviderView(generic.TemplateView):
|
|||
provider['link_count'] = provider_links.count()
|
||||
|
||||
return {'provider': provider, 'links': provider_links}
|
||||
|
||||
class PublishersView(generic.TemplateView):
|
||||
template_name = 'publishers.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
publishers = Item.objects.order_by('publisher_name').values('publisher_name').distinct()
|
||||
for publisher in publishers:
|
||||
publisher['item_count'] = Item.objects.filter(
|
||||
publisher_name=publisher['publisher_name']).count()
|
||||
return {'publisher_list': publishers}
|
||||
|
||||
class PublisherView(generic.TemplateView):
|
||||
template_name = 'publisher.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
pub = kwargs['publisher']
|
||||
publisher = {'publisher': pub}
|
||||
publisher_items = Item.objects.filter(publisher_name=pub)
|
||||
publisher['link_count'] = publisher_items.count()
|
||||
|
||||
return {'publisher': publisher, 'items': publisher_items}
|
||||
|
|
Loading…
Reference in New Issue