Port send SDO reminder admin page to new schema
- Legacy-Id: 3359
This commit is contained in:
parent
89dd9b83ca
commit
1cc908f137
14
ietf/templates/admin/group/group/change_form.html
Normal file
14
ietf/templates/admin/group/group/change_form.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
{% extends "admin/change_form.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block object-tools %}
|
||||
{% if change %}{% if not is_popup %}
|
||||
<ul class="object-tools">
|
||||
{% ifequal original.type_id "sdo" %}
|
||||
<li><a href="reminder/">SDO Authorized List Reminder</a></li>
|
||||
{% endifequal %}
|
||||
<li><a href="history/" class="historylink">{% trans "History" %}</a></li>
|
||||
{% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%}
|
||||
</ul>
|
||||
{% endif %}{% endif %}
|
||||
{% endblock %}
|
16
ietf/templates/admin/group/group/change_list.html
Normal file
16
ietf/templates/admin/group/group/change_list.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
{% extends "admin/change_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
|
||||
{% block object-tools %}
|
||||
{% if has_add_permission %}
|
||||
<ul class="object-tools">
|
||||
<li><a href="reminder/">SDO Authorized List Reminder</a></li>
|
||||
<li>
|
||||
<a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">
|
||||
{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endblock %}
|
47
ietf/templates/admin/group/group/send_sdo_reminder.html
Normal file
47
ietf/templates/admin/group/group/send_sdo_reminder.html
Normal file
|
@ -0,0 +1,47 @@
|
|||
{% extends "admin/base_site.html" %}
|
||||
|
||||
{% load i18n admin_modify adminmedia %}
|
||||
|
||||
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/forms.css" />{% endblock %}
|
||||
|
||||
{% block bodyclass %}change-form{% endblock %}
|
||||
|
||||
{% block breadcrumbs %}{% if not is_popup %}
|
||||
<div class="breadcrumbs">
|
||||
<a href="../../../">{% trans "Home" %}</a> ›
|
||||
<a href="../../">{{ app_label|capfirst|escape }}</a> ›
|
||||
{% if has_change_permission %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} ›
|
||||
{% trans "Send reminder" %}
|
||||
</div>
|
||||
{% endif %}{% endblock %}
|
||||
|
||||
{% block content %}<div id="content-main">
|
||||
<div>
|
||||
<h1>Send a reminder to each SDO Liaison Manager</h1>
|
||||
{% if output %}
|
||||
<p>
|
||||
Reminder sent successfully. See the output of the command:
|
||||
</p>
|
||||
<pre>
|
||||
{{ output }}
|
||||
</pre>
|
||||
{% else %}
|
||||
{% if sdo %}
|
||||
<p>
|
||||
You can send a reminder to the {{ sdo }} SDO Liaison Manager to request an updated list of persons authorized to send liaison statements on behalf of {{ sdo }}</h1>
|
||||
</p>
|
||||
{% else %}
|
||||
<p>
|
||||
You can send a reminder to each SDO Liaison Manager to request an updated list of persons authorized to send liaison statements on behalf of his SDO</h1>
|
||||
</p>
|
||||
<p>
|
||||
By clicking the 'Send' button you will send a request to <b>all</b> the SDO Liaison Managers. In order to send the request to one SDO Liaison Manager go to the SDO edit page.
|
||||
</p>
|
||||
{% endif %}
|
||||
<form action="" method="post">
|
||||
<input type="submit" name="send" value="Send" />
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
12
ietf/templates/admin/group/sdos/change_form.html
Normal file
12
ietf/templates/admin/group/sdos/change_form.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
{% extends "admin/change_form.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block object-tools %}
|
||||
{% if change %}{% if not is_popup %}
|
||||
<ul class="object-tools">
|
||||
<li><a href="reminder/">Update Authorized List Reminder</a></li>
|
||||
<li><a href="history/" class="historylink">{% trans "History" %}</a></li>
|
||||
{% if has_absolute_url %}<li><a href="../../../r/{{ content_type_id }}/{{ object_id }}/" class="viewsitelink">{% trans "View on site" %}</a></li>{% endif%}
|
||||
</ul>
|
||||
{% endif %}{% endif %}
|
||||
{% endblock %}
|
16
ietf/templates/admin/group/sdos/change_list.html
Normal file
16
ietf/templates/admin/group/sdos/change_list.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
{% extends "admin/change_list.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
|
||||
{% block object-tools %}
|
||||
{% if has_add_permission %}
|
||||
<ul class="object-tools">
|
||||
<li><a href="reminder/">Update Authorized List Reminder</a></li>
|
||||
<li>
|
||||
<a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">
|
||||
{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endblock %}
|
47
ietf/templates/admin/group/sdos/send_reminder.html
Normal file
47
ietf/templates/admin/group/sdos/send_reminder.html
Normal file
|
@ -0,0 +1,47 @@
|
|||
{% extends "admin/base_site.html" %}
|
||||
|
||||
{% load i18n admin_modify adminmedia %}
|
||||
|
||||
{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/forms.css" />{% endblock %}
|
||||
|
||||
{% block bodyclass %}change-form{% endblock %}
|
||||
|
||||
{% block breadcrumbs %}{% if not is_popup %}
|
||||
<div class="breadcrumbs">
|
||||
<a href="../../../">{% trans "Home" %}</a> ›
|
||||
<a href="../../">{{ app_label|capfirst|escape }}</a> ›
|
||||
{% if has_change_permission %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} ›
|
||||
{% trans "Send reminder" %}
|
||||
</div>
|
||||
{% endif %}{% endblock %}
|
||||
|
||||
{% block content %}<div id="content-main">
|
||||
<div>
|
||||
<h1>Send a reminder to each SDO Liaison Manager</h1>
|
||||
{% if output %}
|
||||
<p>
|
||||
Reminder sent successfully. See the output of the command:
|
||||
</p>
|
||||
<pre>
|
||||
{{ output }}
|
||||
</pre>
|
||||
{% else %}
|
||||
{% if sdo %}
|
||||
<p>
|
||||
You can send a reminder to the {{ sdo }} SDO Liaison Manager to request an updated list of persons authorized to send liaison statements on behalf of {{ sdo }}</h1>
|
||||
</p>
|
||||
{% else %}
|
||||
<p>
|
||||
You can send a reminder to each SDO Liaison Manager to request an updated list of persons authorized to send liaison statements on behalf of his SDO</h1>
|
||||
</p>
|
||||
<p>
|
||||
By clicking the 'Send' button you will send a request to <b>all</b> the SDO Liaison Managers. In order to send the request to one SDO Liaison Manager go to the SDO edit page.
|
||||
</p>
|
||||
{% endif %}
|
||||
<form action="" method="post">
|
||||
<input type="submit" name="send" value="Send" />
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,13 +1,97 @@
|
|||
from django.contrib import admin
|
||||
from django import template
|
||||
from django.utils.functional import update_wrapper
|
||||
from django.contrib.admin.util import unquote
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.management import load_command_class
|
||||
from django.http import Http404
|
||||
from django.shortcuts import render_to_response
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.utils.functional import update_wrapper
|
||||
from django.utils.html import escape
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from models import *
|
||||
|
||||
class GroupAdmin(admin.ModelAdmin):
|
||||
list_display = ["acronym", "name", "type"]
|
||||
list_display_links = ["acronym", "name"]
|
||||
list_filter = ["type"]
|
||||
search_fields = ["name"]
|
||||
ordering = ["name"]
|
||||
raw_id_fields = ["charter"]
|
||||
raw_id_fields = ["charter", "parent", "ad"]
|
||||
|
||||
def get_urls(self):
|
||||
from django.conf.urls.defaults import patterns, url
|
||||
|
||||
def wrap(view):
|
||||
def wrapper(*args, **kwargs):
|
||||
return self.admin_site.admin_view(view)(*args, **kwargs)
|
||||
return update_wrapper(wrapper, view)
|
||||
|
||||
info = self.model._meta.app_label, self.model._meta.module_name
|
||||
|
||||
urls = patterns('',
|
||||
url(r'^reminder/$',
|
||||
wrap(self.send_reminder),
|
||||
name='%s_%s_reminder' % info),
|
||||
url(r'^(.+)/reminder/$',
|
||||
wrap(self.send_one_reminder),
|
||||
name='%s_%s_one_reminder' % info),
|
||||
)
|
||||
urls += super(GroupAdmin, self).get_urls()
|
||||
return urls
|
||||
|
||||
def send_reminder(self, request, sdo=None):
|
||||
opts = self.model._meta
|
||||
app_label = opts.app_label
|
||||
|
||||
output = None
|
||||
sdo_pk = sdo and sdo.pk or None
|
||||
if request.method == 'POST' and request.POST.get('send', False):
|
||||
command = load_command_class('ietf.liaisons', 'remind_update_sdo_list')
|
||||
output=command.handle(return_output=True, sdo_pk=sdo_pk)
|
||||
output='\n'.join(output)
|
||||
|
||||
context = {
|
||||
'opts': opts,
|
||||
'has_change_permission': self.has_change_permission(request),
|
||||
'app_label': app_label,
|
||||
'output': output,
|
||||
'sdo': sdo,
|
||||
}
|
||||
return render_to_response('admin/group/group/send_sdo_reminder.html',
|
||||
context,
|
||||
context_instance = template.RequestContext(request, current_app=self.admin_site.name),
|
||||
)
|
||||
|
||||
def send_one_reminder(self, request, object_id):
|
||||
model = self.model
|
||||
opts = model._meta
|
||||
|
||||
try:
|
||||
obj = self.queryset(request).get(pk=unquote(object_id))
|
||||
except model.DoesNotExist:
|
||||
obj = None
|
||||
|
||||
if not self.has_change_permission(request, obj):
|
||||
raise PermissionDenied
|
||||
|
||||
if obj is None:
|
||||
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_unicode(opts.verbose_name), 'key': escape(object_id)})
|
||||
|
||||
return self.send_reminder(request, sdo=obj)
|
||||
|
||||
|
||||
admin.site.register(Group, GroupAdmin)
|
||||
admin.site.register(GroupHistory)
|
||||
|
||||
admin.site.register(Role)
|
||||
class RoleAdmin(admin.ModelAdmin):
|
||||
list_display = ["name", "email", "group"]
|
||||
list_display_links = ["name"]
|
||||
search_fields = ["name", "email"]
|
||||
list_filter = ["name"]
|
||||
ordering = ["id"]
|
||||
raw_id_fields = ["email", "group"]
|
||||
|
||||
admin.site.register(Role, RoleAdmin)
|
||||
|
|
|
@ -87,7 +87,7 @@ class Role(models.Model):
|
|||
email = models.ForeignKey(Email, help_text="Email address used by person for this role")
|
||||
auth = models.CharField(max_length=255, blank=True) # unused?
|
||||
def __unicode__(self):
|
||||
return u"%s is %s in %s" % (self.email.get_name(), self.name.name, self.group.acronym)
|
||||
return u"%s is %s in %s" % (self.email.get_name(), self.name.name, self.group.acronym or self.group.name)
|
||||
|
||||
|
||||
class RoleHistory(models.Model):
|
||||
|
|
Loading…
Reference in a new issue