diff options
-rw-r--r-- | devel/admin.py | 8 | ||||
-rw-r--r-- | devel/migrations/0002_staffgroup.py | 31 | ||||
-rw-r--r-- | devel/models.py | 37 | ||||
-rw-r--r-- | public/views.py | 43 | ||||
-rw-r--r-- | sitemaps.py | 3 | ||||
-rw-r--r-- | templates/public/developer_list.html | 4 | ||||
-rw-r--r-- | templates/public/index.html | 6 | ||||
-rw-r--r-- | templates/public/userlist.html | 8 | ||||
-rw-r--r-- | urls.py | 11 |
9 files changed, 86 insertions, 65 deletions
diff --git a/devel/admin.py b/devel/admin.py index c8f80f95..d1729fe3 100644 --- a/devel/admin.py +++ b/devel/admin.py @@ -2,7 +2,7 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User -from .models import UserProfile, MasterKey, DeveloperKey, PGPSignature +from .models import UserProfile, StaffGroup, MasterKey, DeveloperKey, PGPSignature class UserProfileInline(admin.StackedInline): @@ -15,6 +15,11 @@ class UserProfileAdmin(UserAdmin): list_filter = ('is_staff', 'is_superuser', 'is_active') +class StaffGroupAdmin(admin.ModelAdmin): + list_display = ('name', 'group', 'sort_order', 'member_title', 'slug') + prepopulated_fields = {'slug': ('name',)} + + class MasterKeyAdmin(admin.ModelAdmin): list_display = ('pgp_key', 'owner', 'created', 'revoker', 'revoked') search_fields = ('pgp_key', 'owner__username', 'revoker__username') @@ -36,6 +41,7 @@ class PGPSignatureAdmin(admin.ModelAdmin): admin.site.unregister(User) admin.site.register(User, UserProfileAdmin) +admin.site.register(StaffGroup, StaffGroupAdmin) admin.site.register(MasterKey, MasterKeyAdmin) admin.site.register(DeveloperKey, DeveloperKeyAdmin) diff --git a/devel/migrations/0002_staffgroup.py b/devel/migrations/0002_staffgroup.py new file mode 100644 index 00000000..5679e6a3 --- /dev/null +++ b/devel/migrations/0002_staffgroup.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('auth', '0001_initial'), + ('devel', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='StaffGroup', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('name', models.CharField(max_length=100)), + ('slug', models.SlugField(unique=True, max_length=100)), + ('sort_order', models.PositiveIntegerField()), + ('member_title', models.CharField(max_length=100)), + ('description', models.TextField(blank=True)), + ('group', models.OneToOneField(to='auth.Group')), + ], + options={ + 'ordering': ('sort_order',), + }, + bases=(models.Model,), + ), + ] diff --git a/devel/models.py b/devel/models.py index 5c4d4fe7..b05800a5 100644 --- a/devel/models.py +++ b/devel/models.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- import pytz +from django.core.urlresolvers import reverse from django.db import models from django.db.models.signals import pre_save -from django.contrib.auth.models import User +from django.contrib.auth.models import User, Group from django_countries.fields import CountryField from .fields import PGPKeyField @@ -54,17 +55,29 @@ class UserProfile(models.Model): verbose_name_plural = 'additional profile data' def get_absolute_url(self): - # TODO: this is disgusting. find a way to consolidate this logic with - # public.views.userlist among other places, and make some constants or - # something so we aren't using copies of string names everywhere. - group_names = self.user.groups.values_list('name', flat=True) - if "Developers" in group_names: - prefix = "developers" - elif "Trusted Users" in group_names: - prefix = "trustedusers" - else: - prefix = "fellows" - return '/%s/#%s' % (prefix, self.user.username) + user = self.user + group = StaffGroup.objects.filter(group=user.groups.all()).first() + if group: + return '%s#%s' % (group.get_absolute_url(), user.username) + return None + + +class StaffGroup(models.Model): + name = models.CharField(max_length=100) + slug = models.SlugField(max_length=100, unique=True) + group = models.OneToOneField(Group) + sort_order = models.PositiveIntegerField() + member_title = models.CharField(max_length=100) + description = models.TextField(blank=True) + + class Meta: + ordering = ('sort_order',) + + def __unicode__(self): + return self.name + + def get_absolute_url(self): + return reverse('people', args=[self.slug]) class MasterKey(models.Model): diff --git a/public/views.py b/public/views.py index 62d1137a..118f067a 100644 --- a/public/views.py +++ b/public/views.py @@ -5,11 +5,11 @@ from operator import attrgetter from django.conf import settings from django.contrib.auth.models import User from django.db.models import Count, Q -from django.http import Http404, HttpResponse -from django.shortcuts import render +from django.http import HttpResponse +from django.shortcuts import get_object_or_404, render from django.views.decorators.cache import cache_control, cache_page -from devel.models import MasterKey, PGPSignature +from devel.models import MasterKey, PGPSignature, StaffGroup from main.models import Arch, Repo, Donor from mirrors.models import MirrorUrl from news.models import News @@ -28,45 +28,18 @@ def index(request): context = { 'news_updates': News.objects.order_by('-postdate', '-id')[:15], 'pkg_updates': updates, + 'staff_groups': StaffGroup.objects.all(), } return render(request, 'public/index.html', context) -USER_LISTS = { - 'devs': { - 'user_type': 'Developers', - 'user_title': 'Developer', - 'description': "This is a list of the current Arch Linux Developers. They maintain the [core] and [extra] package repositories in addition to doing any other developer duties.", - }, - 'tus': { - 'user_type': 'Trusted Users', - 'user_title': 'Trusted User', - 'description': "Here are all your friendly Arch Linux Trusted Users who are in charge of the [community] repository.", - }, - 'fellows': { - 'user_type': 'Fellows', - 'user_title': 'Fellow', - 'description': "Below you can find a list of ex-developers (aka project fellows). These folks helped make Arch what it is today. Thanks!", - }, -} - @cache_control(max_age=307) -def userlist(request, user_type='devs'): - users = User.objects.order_by( +def people(request, slug): + group = get_object_or_404(StaffGroup, slug=slug) + users = User.objects.filter(groups=group.group).order_by( 'first_name', 'last_name').select_related('userprofile') - if user_type == 'devs': - users = users.filter(is_active=True, groups__name="Developers") - elif user_type == 'tus': - users = users.filter(is_active=True, groups__name="Trusted Users") - elif user_type == 'fellows': - users = users.filter(is_active=False, - groups__name__in=["Developers", "Trusted Users"]) - else: - raise Http404 - users = users.distinct() - context = USER_LISTS[user_type].copy() - context['users'] = users + context = {'group': group, 'users': users} return render(request, 'public/userlist.html', context) diff --git a/sitemaps.py b/sitemaps.py index d79b00b5..eb4e05d9 100644 --- a/sitemaps.py +++ b/sitemaps.py @@ -127,9 +127,6 @@ class BaseSitemap(Sitemap): 'page-about', 'page-art', 'page-svn', - 'page-devs', - 'page-tus', - 'page-fellows', 'page-donate', 'feeds-list', 'mirror-list', diff --git a/templates/public/developer_list.html b/templates/public/developer_list.html index 4401d97b..954216ce 100644 --- a/templates/public/developer_list.html +++ b/templates/public/developer_list.html @@ -21,7 +21,7 @@ <meta itemprop="name" content="{{ dev.get_full_name|escape }}"/> <meta itemprop="givenName" content="{{ dev.first_name|escape }}"/> <meta itemprop="familyName" content="{{ dev.last_name|escape }}"/> - <meta itemprop="jobTitle" content="{{ user_title|escape }}"/> + <meta itemprop="jobTitle" content="{{ group.member_title|escape }}"/> <div style="display:none" itemprop="memberOf" itemscope itemtype="http://schema.org/Organization"> <meta itemprop="name" content="Arch Linux"/> </div> @@ -53,7 +53,7 @@ <th>Occupation:</th> <td>{{ prof.occupation }}</td> </tr><tr> - <th>YOB:</th> + <th>Birth Year:</th> <td itemprop="birthDate">{% if prof.yob %}{{ prof.yob }}{% endif %}</td> </tr><tr> <th>Location:</th> diff --git a/templates/public/index.html b/templates/public/index.html index 3b17803c..c78303ce 100644 --- a/templates/public/index.html +++ b/templates/public/index.html @@ -172,9 +172,9 @@ <h4>People</h4> <ul> - <li><a href="{% url 'page-devs' %}" title="Active developers">Developers</a></li> - <li><a href="{% url 'page-tus' %}" title="Active Trusted Users (TUs)">Trusted Users</a></li> - <li><a href="{% url 'page-fellows' %}" title="Retired Developers">Fellows</a></li> + {% for group in staff_groups %} + <li><a href="{% url 'people' group.slug %}" title="More info about {{ group.name }}">{{ group.name }}</a></li> + {% endfor %} <li><a href="{% url 'page-keys' %}" title="Package/Database signing master keys">Signing Master Keys</a></li> </ul> diff --git a/templates/public/userlist.html b/templates/public/userlist.html index 35104317..b49c5de2 100644 --- a/templates/public/userlist.html +++ b/templates/public/userlist.html @@ -2,16 +2,16 @@ {% load static from staticfiles %} {% load cache %} -{% block title %}Arch Linux - {{ user_type }}{% endblock %} +{% block title %}Arch Linux - {{ group.name }}{% endblock %} {% block head %}<link rel="stylesheet" type="text/css" href="{% static "flags/fam.css" %}" media="screen, projection" />{% endblock %} {% block content %} -{% cache 600 dev-tu-profiles user_type %} +{% cache 600 dev-tu-profiles group.name %} <div id="dev-tu-profiles" class="box"> - <h2>Arch Linux {{user_type}}</h2> + <h2>Arch Linux {{ group.name }}</h2> - <p>{{description}}</p> + <p>{{ group.description }}</p> {% with users as dev_list %} {% include 'public/developer_list.html' %} @@ -29,13 +29,11 @@ urlpatterns += patterns('public.views', {}, 'page-art'), (r'^svn/$', TemplateView.as_view(template_name='public/svn.html'), {}, 'page-svn'), - (r'^developers/$', 'userlist', { 'user_type':'devs' }, 'page-devs'), - (r'^trustedusers/$', 'userlist', { 'user_type':'tus' }, 'page-tus'), - (r'^fellows/$', 'userlist', { 'user_type':'fellows' }, 'page-fellows'), (r'^donate/$', 'donate', {}, 'page-donate'), (r'^download/$', 'download', {}, 'page-download'), (r'^master-keys/$', 'keys', {}, 'page-keys'), (r'^master-keys/json/$', 'keys_json', {}, 'pgp-keys-json'), + (r'^people/(?P<slug>[-\w]+)/$', 'people', {}, 'people'), ) # Feeds patterns, used below @@ -98,15 +96,18 @@ urlpatterns += patterns('django.contrib.auth.views', legacy_urls = ( ('^about.php', '/about/'), ('^changelog.php', '/packages/?sort=-last_update'), - ('^devs.php', '/developers/'), + ('^devs.php', '/people/developers/'), ('^donations.php', '/donate/'), ('^download.php', '/download/'), ('^index.php', '/'), ('^logos.php', '/art/'), ('^news.php', '/news/'), ('^packages.php', '/packages/'), - ('^people.php', '/developers/'), + ('^people.php', '/people/developers/'), ('^todolists/$', '/todo/'), + ('^developers/$', '/people/developers/'), + ('^fellows/$', '/people/developer-fellows/'), + ('^trustedusers/$', '/people/trusted-users/'), ('^docs/en/guide/install/arch-install-guide.html', 'https://wiki.archlinux.org/index.php/Installation_guide'), |