Refactored the new AD dashboard view to re-use code and templates the same way the refactored previous view did.
- Legacy-Id: 5846
This commit is contained in:
parent
cf3fac2959
commit
55d8a49b57
|
@ -41,6 +41,7 @@ urlpatterns = patterns('',
|
|||
url(r'^search/$', views_search.search, name="doc_search"),
|
||||
url(r'^in-last-call/$', views_search.drafts_in_last_call, name="drafts_in_last_call"),
|
||||
url(r'^ad/(?P<name>[A-Za-z0-9.-]+)/$', views_search.drafts_for_ad, name="drafts_for_ad"),
|
||||
# url(r'^ad2/(?P<name>[A-Za-z0-9.-]+)/$', views_search.docs_for_ad, name="docs_for_ad"),
|
||||
url(r'^ad2/(?P<name>[A-Za-z0-9.-]+)/$', views_search.docs_for_ad, name="docs_for_ad"),
|
||||
|
||||
# (r'^all/$', views_search.all), # XXX CHECK MERGE
|
||||
|
|
|
@ -196,7 +196,7 @@ def fill_in_search_attributes(docs):
|
|||
l.sort()
|
||||
|
||||
|
||||
def retrieve_search_results(form):
|
||||
def retrieve_search_results(form, types=['draft']):
|
||||
"""Takes a validated SearchForm and return the results."""
|
||||
if not form.is_valid():
|
||||
raise ValueError("SearchForm doesn't validate: %s" % form.errors)
|
||||
|
@ -208,7 +208,10 @@ def retrieve_search_results(form):
|
|||
|
||||
MAX = 500
|
||||
|
||||
docs = Document.objects.filter(type="draft")
|
||||
if types and len(types) > 0:
|
||||
docs = Document.objects.filter(type__in=types)
|
||||
else:
|
||||
docs = Document.objects.all()
|
||||
|
||||
# name
|
||||
if query["name"]:
|
||||
|
@ -216,15 +219,16 @@ def retrieve_search_results(form):
|
|||
Q(title__icontains=query["name"])).distinct()
|
||||
|
||||
# rfc/active/old check buttons
|
||||
allowed_states = []
|
||||
if query["rfcs"]:
|
||||
allowed_states.append("rfc")
|
||||
if query["activedrafts"]:
|
||||
allowed_states.append("active")
|
||||
if query["olddrafts"]:
|
||||
allowed_states.extend(['repl', 'expired', 'auth-rm', 'ietf-rm'])
|
||||
if types == ['draft']:
|
||||
allowed_states = []
|
||||
if query["rfcs"]:
|
||||
allowed_states.append("rfc")
|
||||
if query["activedrafts"]:
|
||||
allowed_states.append("active")
|
||||
if query["olddrafts"]:
|
||||
allowed_states.extend(['repl', 'expired', 'auth-rm', 'ietf-rm'])
|
||||
|
||||
docs = docs.filter(states__type="draft", states__slug__in=allowed_states)
|
||||
docs = docs.filter(states__type="draft", states__slug__in=allowed_states)
|
||||
|
||||
# radio choices
|
||||
by = query["by"]
|
||||
|
@ -342,36 +346,6 @@ def search(request):
|
|||
{'form':form, 'docs':results, 'meta':meta, 'show_add_to_list': True },
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
def drafts_for_ad(request, name):
|
||||
ad = None
|
||||
responsible = Document.objects.values_list('ad', flat=True).distinct()
|
||||
for p in Person.objects.filter(Q(role__name__in=("pre-ad", "ad"),
|
||||
role__group__type="area",
|
||||
role__group__state="active")
|
||||
| Q(pk__in=responsible)).distinct():
|
||||
if name == p.full_name_as_key():
|
||||
ad = p
|
||||
break
|
||||
if not ad:
|
||||
raise Http404
|
||||
form = SearchForm({'by':'ad','ad': ad.id,
|
||||
'rfcs':'on', 'activedrafts':'on', 'olddrafts':'on',
|
||||
'sort': 'status'})
|
||||
results, meta = retrieve_search_results(form)
|
||||
|
||||
for d in results:
|
||||
if d.get_state_slug() == "active":
|
||||
iesg_state = d.get_state("draft-iesg")
|
||||
if iesg_state:
|
||||
if iesg_state.slug == "dead":
|
||||
d.search_heading = "IESG Dead Internet-Drafts"
|
||||
else:
|
||||
d.search_heading = "%s Internet-Drafts" % iesg_state.name
|
||||
|
||||
return render_to_response('doc/drafts_for_ad.html',
|
||||
{ 'form':form, 'docs':results, 'meta':meta, 'ad_name': ad.plain_name() },
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
def ad_dashboard_group(doc):
|
||||
|
||||
if doc.type.slug=='draft':
|
||||
|
@ -457,7 +431,37 @@ def ad_dashboard_sort_key(doc):
|
|||
return "1%d%s%s%010d" % (state[0].order,seed,doc.type.slug,ageseconds)
|
||||
|
||||
return "3%s" % seed
|
||||
|
||||
|
||||
def drafts_for_ad(request, name):
|
||||
ad = None
|
||||
responsible = Document.objects.values_list('ad', flat=True).distinct()
|
||||
for p in Person.objects.filter(Q(role__name__in=("pre-ad", "ad"),
|
||||
role__group__type="area",
|
||||
role__group__state="active")
|
||||
| Q(pk__in=responsible)).distinct():
|
||||
if name == p.full_name_as_key():
|
||||
ad = p
|
||||
break
|
||||
if not ad:
|
||||
raise Http404
|
||||
form = SearchForm({'by':'ad','ad': ad.id,
|
||||
'rfcs':'on', 'activedrafts':'on', 'olddrafts':'on',
|
||||
'sort': 'status'})
|
||||
results, meta = retrieve_search_results(form)
|
||||
del meta["headers"][-1]
|
||||
#
|
||||
for d in results:
|
||||
if d.get_state_slug() == "active":
|
||||
iesg_state = d.get_state("draft-iesg")
|
||||
if iesg_state:
|
||||
if iesg_state.slug == "dead":
|
||||
d.search_heading = "IESG Dead Internet-Drafts"
|
||||
else:
|
||||
d.search_heading = "%s Internet-Drafts" % iesg_state.name
|
||||
return render_to_response('doc/drafts_for_ad.html',
|
||||
{ 'form':form, 'docs':results, 'meta':meta, 'ad_name': ad.plain_name() },
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
def docs_for_ad(request, name):
|
||||
ad = None
|
||||
responsible = Document.objects.values_list('ad', flat=True).distinct()
|
||||
|
@ -470,37 +474,19 @@ def docs_for_ad(request, name):
|
|||
break
|
||||
if not ad:
|
||||
raise Http404
|
||||
|
||||
docqueryset = Document.objects.filter(ad__id=ad.id)
|
||||
docs=[]
|
||||
for doc in docqueryset:
|
||||
doc.ad_dashboard_sort_key = ad_dashboard_sort_key(doc)
|
||||
doc.ad_dashboard_group = ad_dashboard_group(doc)
|
||||
if doc.get_state_slug() == 'rfc':
|
||||
doc.display_date = doc.latest_event(type='published_rfc').time
|
||||
else:
|
||||
revision = doc.latest_event(type='new_revision')
|
||||
if revision:
|
||||
doc.display_date = revision.time
|
||||
# This might be better handled as something Documents know about themselves
|
||||
now = datetime.datetime.now()
|
||||
doc.can_expire = (doc.type.slug=='draft' and doc.get_state_slug('draft')=='active' and ( not doc.get_state('draft-iesg') or doc.get_state('draft-iesg').order >= 42) and doc.expires>now)
|
||||
if doc.get_state_slug('draft') == 'rfc':
|
||||
doc.obsoleted_by = ", ".join([ 'RFC %04d' % int(rel.source.rfc_number()) for alias in doc.docalias_set.all() for rel in alias.relateddocument_set.filter(relationship='obsoletes') ] )
|
||||
doc.updated_by = ", ".join([ 'RFC %04d' % int(rel.source.rfc_number()) for alias in doc.docalias_set.all() for rel in alias.relateddocument_set.filter(relationship='updates') ] )
|
||||
doc.has_errata = bool(doc.tags.filter(slug="errata"))
|
||||
else:
|
||||
s = doc.get_state("draft-rfceditor")
|
||||
if s:
|
||||
# extract possible extra annotations
|
||||
tags = doc.tags.filter(slug__in=("iana", "ref"))
|
||||
doc.rfc_editor_state = "*".join([s.name] + [t.slug.upper() for t in tags])
|
||||
if doc.type.slug == 'draft':
|
||||
doc.iprCount = IprDocAlias.objects.filter(doc_alias__document=doc, ipr__status__in=[1,3]).count()
|
||||
doc.iprUrl = "/ipr/search?option=document_search&id_document_tag=%s" % doc.name
|
||||
docs.append(doc)
|
||||
docs.sort(key=ad_dashboard_sort_key)
|
||||
return render_to_response('doc/by_ad2.html',{'docs':docs,'ad_name':ad.plain_name()}, context_instance=RequestContext(request))
|
||||
form = SearchForm({'by':'ad','ad': ad.id,
|
||||
'rfcs':'on', 'activedrafts':'on', 'olddrafts':'on',
|
||||
'sort': 'status'})
|
||||
results, meta = retrieve_search_results(form, types=None)
|
||||
results.sort(key=ad_dashboard_sort_key)
|
||||
del meta["headers"][-1]
|
||||
#
|
||||
for d in results:
|
||||
d.search_heading = ad_dashboard_group(d)
|
||||
#
|
||||
return render_to_response('doc/drafts_for_ad.html',
|
||||
{ 'form':form, 'docs':results, 'meta':meta, 'ad_name': ad.plain_name() },
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
def drafts_in_last_call(request):
|
||||
lc_state = State.objects.get(type="draft-iesg", slug="lc").pk
|
||||
|
|
|
@ -40,7 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
<li><a href="{% url account_index %}">{% if request.user.is_authenticated %}Manage Account{% else %}New Account{% endif %}</a></li>
|
||||
{% if user|has_role:"Area Director" %}
|
||||
<li class="sect first">AD Dashboard</li>
|
||||
<li><a href="{% url drafts_for_ad name=user.get_profile.full_name_as_key %}">My Documents</a></li>
|
||||
<li><a href="{% url drafts_for_ad name=user.get_profile.full_name_as_key %}">My Documents (Old)</a></li>
|
||||
<li><a href="{% url docs_for_ad name=user.get_profile.full_name_as_key %}">My Documents (New)</a></li>
|
||||
<li><a href="{% url ietf.iesg.views.agenda_documents %}">Next Telechat</a></li>
|
||||
<li><a href="{% url ietf.iesg.views.discusses %}">Discusses</a></li>
|
||||
<li><a href="{% url ietf.iesg.views.milestones_needing_review %}">Milestones</a></li>
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load ietf_filters %}
|
||||
{% load ietf_streams_redesign %}
|
||||
{% load ballot_icon_redesign %}
|
||||
|
||||
{% block title %}Documents for {{ ad_name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Documents for {{ ad_name }}</h1>
|
||||
|
||||
{% regroup docs by ad_dashboard_group as grouped_docs %}
|
||||
|
||||
<table class="ietf-table ietf-doctable">
|
||||
<tr><th class="doc">Document</th><th class="title">Title</th><th class="date">Date</th><th class="status" colspan="2">Status</th><th class="ipr">ipr</th></tr>
|
||||
{% for doc_group in grouped_docs %}
|
||||
<tr class="header"><td colspan="7">{{doc_group.grouper}}s</td></tr>
|
||||
|
||||
{% for doc in doc_group.list %}
|
||||
|
||||
|
||||
<tr class="{{ forloop.counter|divisibleby:2|yesno:"oddrow,evenrow" }}">
|
||||
|
||||
<td class="doc">
|
||||
{#{{doc.ad_dashboard_sort_key}}<br/>#}
|
||||
{% if doc.get_state_slug == 'rfc' %}
|
||||
{{ doc.canonical_name|upper|rfcspace|urlize_ietf_docs }}<br/>{{ doc.name|urlize_ietf_docs }}
|
||||
{% else %}
|
||||
{{ doc.name|urlize_ietf_docs }}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="title">{{ doc.title }}</td>
|
||||
|
||||
|
||||
<td class="date">
|
||||
{% if doc.display_date %}
|
||||
{% if doc.get_state_slug == 'rfc' %}
|
||||
{{ doc.display_date|date:"Y-m"}}
|
||||
{% else %}
|
||||
{{ doc.display_date|date:"Y-m-d" }}
|
||||
{% endif %}
|
||||
{% if doc.display_date|timesince_days|new_enough:request %}
|
||||
<br/><span class="ietf-small ietf-highlight-y">
|
||||
{% if not doc.type.slug == 'draft' or doc.get_state_slug == 'rfc' %}
|
||||
new
|
||||
{% else %}
|
||||
<a href="http:{{rfcdiff_prefix}}?url2={{doc.filename_with_rev}}">new</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if doc.can_expire and doc.expires and doc.expires|timesince_days|expires_soon:request %}
|
||||
<br/><span class="ietf-small ietf-highlight-y">expires soon</span>
|
||||
{%endif%}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td class="status">
|
||||
{{ doc.friendly_state|safe }} {% if not doc.get_state_slug == 'rfc' %}{{ doc|state_age_colored|safe }}{% endif %}
|
||||
{% if doc.on_upcoming_agenda %}<br/>IESG Telechat: {{ doc.telechat_date }}{% endif %}
|
||||
{% if doc.get_state_slug == 'rfc' %}
|
||||
{% if doc.obsoleted_by %}<br />Obsoleted by {{ doc.obsoleted_by|urlize_ietf_docs }}{%endif %}
|
||||
{% if doc.updated_by %}<br />Updated by {{ doc.updated_by|urlize_ietf_docs }}{%endif %}
|
||||
{% if doc.has_errata %}<br /><a href="http://www.rfc-editor.org/errata_search.php?rfc={{doc.rfc_number}}" rel="nofollow">Errata</a>{% endif %}
|
||||
{% else %}{# not rfc #}
|
||||
{% if doc.rfc_editor_state %}<br />RFC Editor State: <a href="http://www.rfc-editor.org/queue2.html#{{doc.name}}">{{ doc.rfc_editor_state|escape }}</a>{% endif %}
|
||||
{% stream_state doc %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="ballot">
|
||||
{% ballot_icon doc %}
|
||||
</td>
|
||||
|
||||
|
||||
<td class="ipr">
|
||||
{% if doc.iprCount %}<a href="{{ doc.iprUrl }}" rel="nofollow"> {{ doc.iprCount }} </a>{% endif %}
|
||||
</td>
|
||||
|
||||
{% comment %}
|
||||
{% include "idrfc/ipr_column.html" %}
|
||||
{% endcomment %}
|
||||
</tr>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endblock content %}
|
|
@ -1,9 +1,9 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Internet-Drafts and RFCs for {{ ad_name }}{% endblock %}
|
||||
{% block title %}Documents for {{ ad_name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Internet-Drafts and RFCs for {{ ad_name }}</h1>
|
||||
<h1>Documents for {{ ad_name }}</h1>
|
||||
|
||||
{% include "idrfc/search_results.html" %}
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
{% endif %}
|
||||
</td>
|
||||
|
||||
{% if ad_name != doc.ad.plain_name %}
|
||||
<td class="ad">{{ doc.ad|default:"" }}<div class="search-text-shepherd">{{doc.shepherd|default:""}}</div></td>
|
||||
{% endif %}
|
||||
|
||||
</tr>
|
||||
|
|
|
@ -61,7 +61,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
{% regroup docs by search_heading as grouped_docs %}
|
||||
|
||||
{% for doc_group in grouped_docs %}
|
||||
<tr class="header"><td colspan="10">{{ doc_group.grouper }}</td></tr>
|
||||
<tr class="header"><td colspan="10">{{ doc_group.grouper }}{{doc_group.list|length|pluralize}}</td></tr>
|
||||
|
||||
{% for doc in doc_group.list %}
|
||||
{% include "idrfc/search_result_row.html" %}
|
||||
|
|
Loading…
Reference in a new issue