Commit 875d50d8 authored by Jelle van der Waa's avatar Jelle van der Waa 🚧 Committed by Angel Velásquez
Browse files

Remove unused Iso Model (#82)

The ISO model was used for the releng feedback form which was removed
earlier. All this code is therefore now unused.
parent 15e4f753
......@@ -229,21 +229,6 @@
"fields": {
"name": "Release Engineering",
"permissions": [
[
"add_iso",
"releng",
"iso"
],
[
"change_iso",
"releng",
"iso"
],
[
"delete_iso",
"releng",
"iso"
],
[
"add_release",
"releng",
......
from django.contrib import admin
from .models import (Iso, Release)
class IsoAdmin(admin.ModelAdmin):
list_display = ('name', 'created', 'active', 'removed')
list_filter = ('active', 'created')
date_hierarchy = 'created'
class TestAdmin(admin.ModelAdmin):
list_display = ('user_name', 'user_email', 'created', 'ip_address',
'iso', 'success')
list_filter = ('success', 'iso')
from .models import Release
class ReleaseAdmin(admin.ModelAdmin):
list_display = ('version', 'release_date', 'kernel_version', 'available',
......@@ -19,7 +9,6 @@ class ReleaseAdmin(admin.ModelAdmin):
readonly_fields = ('created', 'last_modified')
admin.site.register(Iso, IsoAdmin)
admin.site.register(Release, ReleaseAdmin)
# vim: set ts=4 sw=4 et:
import re
import urllib
from HTMLParser import HTMLParser, HTMLParseError
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.utils.timezone import now
from releng.models import Iso
class IsoListParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.hyperlinks = []
self.url_re = re.compile('(?!\.{2})/$')
def handle_starttag(self, tag, attrs):
if tag != 'a':
return
for name, value in attrs:
if name != "href":
continue
if value != '../' and self.url_re.search(value) is not None:
self.hyperlinks.append(value[:-1])
def parse(self, url):
try:
remote_file = urllib.urlopen(url)
data = remote_file.read()
remote_file.close()
self.feed(data)
self.close()
return self.hyperlinks
except HTMLParseError:
raise CommandError('Couldn\'t parse "%s"' % url)
class Command(BaseCommand):
help = 'Gets new ISOs from %s' % settings.ISO_LIST_URL
def handle(self, *args, **options):
parser = IsoListParser()
isonames = Iso.objects.values_list('name', flat=True)
try:
active_isos = parser.parse(settings.ISO_LIST_URL)
except IOError as e:
print('Unable to fetch active isos from {}'.format(settings.ISO_LIST_URL))
if options.get('verbosity') > 1:
print(e)
return
for iso in active_isos:
# create any names that don't already exist
if iso not in isonames:
new = Iso(name=iso, active=True)
new.save()
# update those that do if they were marked inactive
else:
existing = Iso.objects.get(name=iso)
if not existing.active:
existing.active = True
existing.removed = None
existing.save(update_fields=('active', 'removed'))
# and then mark all other names as no longer active
Iso.objects.filter(active=True).exclude(name__in=active_isos).update(
active=False, removed=now())
# vim: set ts=4 sw=4 et:
......@@ -13,22 +13,6 @@
from main.utils import set_created_field, parse_markdown
class Iso(models.Model):
name = models.CharField(max_length=255)
created = models.DateTimeField(editable=False)
removed = models.DateTimeField(null=True, blank=True, default=None)
active = models.BooleanField(default=True)
def get_absolute_url(self):
return reverse('releng-results-iso', args=[self.pk])
def __unicode__(self):
return self.name
class Meta:
verbose_name = 'ISO'
class Release(models.Model):
release_date = models.DateField(db_index=True)
version = models.CharField(max_length=50, unique=True)
......@@ -103,8 +87,6 @@ def torrent(self):
return metadata
for model in (Iso, Release):
pre_save.connect(set_created_field, sender=model,
dispatch_uid="releng.models")
pre_save.connect(set_created_field, sender=Release, dispatch_uid="releng.models")
# vim: set ts=4 sw=4 et:
......@@ -3,35 +3,14 @@
from django.core.serializers.json import DjangoJSONEncoder
from django.core.urlresolvers import reverse
from django.db.models import Count
from django.http import Http404, HttpResponse
from django.shortcuts import get_object_or_404, render
from django.views.generic import DetailView, ListView
from .models import (Iso, Release)
from .models import Release
from mirrors.models import MirrorUrl
def iso_overview(request):
isos = Iso.objects.all().order_by('-pk')
successes = dict(Iso.objects.values_list('pk').filter(
test__success=True).annotate(ct=Count('test')))
failures = dict(Iso.objects.values_list('pk').filter(
test__success=False).annotate(ct=Count('test')))
for iso in isos:
iso.successes = successes.get(iso.pk, 0)
iso.failures = failures.get(iso.pk, 0)
# only show "useful" rows, currently active ISOs or those with results
isos = [iso for iso in isos if
iso.active is True or iso.successes > 0 or iso.failures > 0]
context = {
'isos': isos
}
return render(request, 'releng/iso_overview.html', context)
class ReleaseListView(ListView):
model = Release
......
......@@ -135,9 +135,6 @@
PGP_SERVER = 'pgp.mit.edu'
PGP_SERVER_SECURE = True
# URL to fetch a current list of available ISOs
ISO_LIST_URL = 'https://releng.archlinux.org/isos/'
# URL for SVN access for fetching commit messages (note absence of packages or
# community bit on the end, repo.svn_root is appended)
SVN_BASE_URL = 'svn://svn.archlinux.org/'
......
{% extends "base.html" %}
{% load static from staticfiles %}
{% block content %}
<div class="box">
<h2>Failures and Successes for Testing ISOs</h2>
<p>This is an overview showing all current or tested release engineering
produced ISOs. Past but now unavailable ISOs are ommitted if there were
never any testing results submitted. To help improve ISO quality, you are
encouraged to <a href="{% url 'releng-test-submit' %}">give feedback</a>
if you have tested and used any ISOs. Both successful and failed results
are encouraged and welcome.</p>
<p><a href="{% url 'releng-test-overview' %}">Go back to testing results</a></p>
<table id="releng-result" class="results">
<thead>
<tr>
<th>ISO</th>
<th>Currently Available</th>
<th># Successes</th>
<th># Failures</th>
</tr>
</thead>
<tbody>
{% for iso in isos %}
<tr>
<td>
<a href="{{ iso.get_absolute_url }}">{{ iso.name }}</a>
</td>
<td>{{ iso.active|yesno|capfirst }}</td>
<td>{{ iso.successes }}</td>
<td>{{ iso.failures }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
{% block script_block %}
{% load cdn %}{% jquery %}{% jquery_tablesorter %}
<script type="text/javascript" src="{% static "archweb.js" %}"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".results:not(:has(tbody tr.empty))").tablesorter({widgets: ['zebra']});
});
</script>
{% endblock %}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment