Skip to content

Commit

Permalink
Merged in Lars Eggert's changes to the search page, and Henrik's left…
Browse files Browse the repository at this point in the history
…hand-menu addition

 - Legacy-Id: 1255
  • Loading branch information
levkowetz committed Nov 18, 2008
1 parent ce26647 commit 4506cb4
Show file tree
Hide file tree
Showing 68 changed files with 1,053 additions and 768 deletions.
2 changes: 0 additions & 2 deletions ietf/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/*.swp
/*.pyc
/settings_local.py
1 change: 0 additions & 1 deletion ietf/idtracker/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/*.pyc
/settings_local.py
1 change: 1 addition & 0 deletions ietf/idtracker/fixtures/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*.pyc
2 changes: 1 addition & 1 deletion ietf/idtracker/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class IDSearch(forms.Form):
search_job_owner = forms.ChoiceField(choices=(), required=False)
search_group_acronym = forms.CharField(widget=forms.TextInput(attrs={'size': 6, 'maxlength': 10}), required=False)
search_group_acronym = forms.CharField(widget=forms.TextInput(attrs={'size': 7, 'maxlength': 10}), required=False)
search_status_id = forms.ModelChoiceField(IDStatus.objects.all(), empty_label="--All", required=False)
search_area_acronym = forms.ModelChoiceField(Area.objects.filter(status=Area.ACTIVE), empty_label="--All/Any", required=False)
search_cur_state = forms.ModelChoiceField(IDState.objects.all(), empty_label="--All/Any", required=False)
Expand Down
53 changes: 42 additions & 11 deletions ietf/idtracker/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright The IETF Trust 2007, All Rights Reserved

from django.conf import settings
from django.db import models
from ietf.utils import FKAsOneToOne
from django.test import TestCase
Expand Down Expand Up @@ -117,6 +118,7 @@ class Admin:
pass

class InternetDraft(models.Model):
DAYS_TO_EXPIRE=185
id_document_tag = models.AutoField(primary_key=True)
title = models.CharField(maxlength=255, db_column='id_document_name')
id_document_key = models.CharField(maxlength=255, editable=False)
Expand Down Expand Up @@ -153,9 +155,19 @@ def save(self):
self.id_document_key = self.title.upper()
super(InternetDraft, self).save()
def displayname(self):
return "%s-%s.txt" % ( self.filename, self.revision_display() )
if self.status.status == "Replaced":
css="replaced"
else:
css="active"
return '<span class="' + css + '">' + self.filename + '</span>'
def displayname_with_link(self):
if self.status.status == "Replaced":
css="replaced"
else:
css="active"
return '<a class="' + css + '" href="%s">%s</a>' % ( self.doclink(), self.filename )
def doclink(self):
return "http://www.ietf.org/internet-drafts/%s" % ( self.displayname() )
return "http://" + settings.TOOLS_SERVER + "/html/%s" % ( self.filename )
def group_acronym(self):
return self.group.acronym
def __str__(self):
Expand All @@ -176,12 +188,26 @@ def doctype(self):
def filename_with_link(self, text=None):
if text is None:
text=self.filename
if self.status.status != 'Active':
return text
else:
return '<a href="%s">%s</a>' % ( self.doclink(), text )
def displayname_with_link(self):
return self.filename_with_link(self.displayname())
return '<a href="%s">%s</a>' % ( self.doclink(), text )
def expiration(self):
return self.revision_date + datetime.timedelta(self.DAYS_TO_EXPIRE)
def can_expire(self):
# Copying the logic from expire-ids-1 without thinking
# much about it.
if self.review_by_rfc_editor:
return False
idinternal = self.idinternal
if idinternal:
cur_state_id = idinternal.cur_state_id
# 42 is "AD is Watching"; this matches what's in the
# expire-ids-1 perl script.
# A better way might be to add a column to the table
# saying whether or not a document is prevented from
# expiring.
if cur_state_id < 42:
return False
return True

class Meta:
db_table = "internet_drafts"
class Admin:
Expand Down Expand Up @@ -364,7 +390,7 @@ def revision(self):
def revision_display(self):
return "RFC"
def doclink(self):
return "http://www.ietf.org/rfc/%s" % ( self.displayname() )
return "http://" + settings.TOOLS_SERVER + "/html/%s" % ( self.displayname() )
def doctype(self):
return "RFC"
def filename_with_link(self):
Expand Down Expand Up @@ -581,12 +607,17 @@ def get_author(self):
if self.created_by_id and self.created_by_id != 999:
return self.created_by.__str__()
else:
return "system"
return "(System)"
def get_username(self):
if self.created_by_id and self.created_by_id != 999:
return self.created_by.login_name
else:
return "system"
return "(System)"
def get_fullname(self):
if self.created_by_id and self.created_by_id != 999:
return self.created_by.first_name + " " + self.created_by.last_name
else:
return "(System)"
def datetime(self):
# this is just a straightforward combination, except that the time is
# stored incorrectly in the database.
Expand Down
1 change: 0 additions & 1 deletion ietf/idtracker/templatetags/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/*.pyc
/settings_local.py
59 changes: 59 additions & 0 deletions ietf/idtracker/templatetags/ietf_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ def allononeline(text):
"""Simply removes CRs, LFs, leading and trailing whitespace from the given string."""
return text.replace("\r", "").replace("\n", "").strip()

@register.filter(name='allononelinew')
def allononelinew(text):
"""Map runs of whitespace to a single space and strip leading and trailing whitespace from the given string."""
return re.sub("[\r\n\t ]+", " ", text).strip()

@register.filter(name='rfcspace')
def rfcspace(string):
"""
Expand Down Expand Up @@ -213,9 +218,63 @@ def inpast(date):
return date < datetime.datetime.now()
return True

@register.filter(name='truncatemore')
def truncatemore(text, arg):
"""Truncate the text if longer than 'words', and if truncated,
add a link to the full text (given in 'link').
"""
from django.utils.text import truncate_words
args = arg.split(",")
if len(args) == 3:
count, link, format = args
elif len(args) == 2:
format = "[<a href='%s'>more</a>]"
count, link = args
else:
return text
try:
length = int(count)
except ValueError: # invalid literal for int()
return text # Fail silently.
if not isinstance(text, basestring):
text = str(text)
words = text.split()
if len(words) > length:
words = words[:length]
words.append(format % link)
return ' '.join(words)

@register.filter(name="wrap_long_lines")
def wrap_long_lines(text):
"""Wraps long lines without loosing the formatting and indentation
of short lines"""
if type(text) != type(""):
return text
text = re.sub(" *\r\n", "\n", text) # get rid of DOS line endings
text = re.sub(" *\r", "\n", text) # get rid of MAC line endings
text = re.sub("( *\n){3,}", "\n\n", text) # get rid of excessive vertical whitespace
lines = text.split("\n")
filled = []
wrapped = False
for line in lines:
if wrapped and line.strip() != "":
line = filled[-1] + " " + line
filled = filled[:-1]
else:
wrapped = False
while (len(line) > 80) and (" " in line[:80]):
wrapped = True
breakpoint = line.rfind(" ",0,79)
filled += [ line[:breakpoint] ]
line = line[breakpoint+1:]
filled += [ line.rstrip() ]
return "\n".join(filled)

def _test():
import doctest
doctest.testmod()

if __name__ == "__main__":
_test()


24 changes: 21 additions & 3 deletions ietf/idtracker/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,24 @@ def search(request):
if status != '':
q_objs.append(Q(draft__status=status,rfc_flag=0))
matches = IDInternal.objects.all().filter(*q_objs)
matches = matches.order_by('cur_state', 'cur_sub_state', '-primary_flag')
matches = matches.order_by('cur_state', 'cur_sub_state', 'ballot_id', '-primary_flag')
# sort by date in reverse
# first build docstate groups, within which we sort
# in each docstate group, we build ballot id groups, which we sort
m1 = [] # list of: docstate, list of: event date; ballot id; list of: ms for the ballot id
for m in matches:
if m1 and m1[-1][0] == m.docstate():
if m1[-1][1] and m1[-1][1][0][1] == m.ballot_id:
m1[-1][1][0][2].append(m)
else:
m1[-1][1].append((m.event_date, m.ballot_id, [m]))
else:
m1.append((m.docstate(), [(m.event_date, m.ballot_id, [m])]))
matches = []
for ms in m1: ms[1].sort(reverse=True)
for ms in m1:
for mt in ms[1]:
matches.extend(mt[2])
#
# Now search by I-D exists, if there could be any results.
# If searching by job owner, current state or substate, there
Expand Down Expand Up @@ -119,6 +136,7 @@ def search(request):
'form': form,
'matches': matches,
'searching': searching,
'spacing': True
}, context_instance=RequestContext(request))

# proof of concept, orphaned for now
Expand Down Expand Up @@ -209,7 +227,7 @@ def view_id(request, queryset, slug, slug_field):
except IDInternal.DoesNotExist:
draft = get_object_or_404(InternetDraft, filename=slug)
return render_to_response('idtracker/idinternal_notfound.html', {'draft': draft}, context_instance=RequestContext(request))
return render_to_response('idtracker/idinternal_detail.html', {'object': object}, context_instance=RequestContext(request))
return render_to_response('idtracker/idinternal_detail.html', {'object': object, 'spacing': False}, context_instance=RequestContext(request))

def view_rfc(request, object_id):
'''A replacement for the object_detail generic view for this
Expand All @@ -223,7 +241,7 @@ def view_rfc(request, object_id):
This view gets the appropriate row from IDInternal and
calls the template with the necessary context.'''
object = get_object_or_404(IDInternal, pk=object_id, rfc_flag=1)
return render_to_response('idtracker/idinternal_detail.html', {'object': object}, context_instance=RequestContext(request))
return render_to_response('idtracker/idinternal_detail.html', {'object': object, 'spacing': False}, context_instance=RequestContext(request))

# Wrappers around object_detail to give permalink a handle.
# The named-URLs feature in django 0.97 will eliminate the
Expand Down
1 change: 0 additions & 1 deletion ietf/proceedings/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/*.pyc
/settings_local.py
75 changes: 75 additions & 0 deletions ietf/proceedings/feeds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import re
from django.contrib.syndication.feeds import Feed
from django.utils.feedgenerator import Atom1Feed
from ietf.proceedings.models import WgProceedingsActivities
from ietf.proceedings.models import Slide, WgAgenda, Proceeding
from datetime import datetime, time
from django.db import connection

class LatestWgProceedingsActivity(Feed):
feed_type = Atom1Feed
link = "/foo"
description = "foobar"
language = "en"
feed_url = "/feed/ipr/"
base_url = "http://www3.ietf.org/proceedings/"

def items(self):
objs = []
for act in WgProceedingsActivities.objects.order_by('-act_date')[:60]:
obj = {}

m = re.match("^slide, '(.*)', was uploaded$", act.activity)
if m:
obj['title'] = m.group(1)
obj['title'] = re.sub("[^ -~]+", "", obj['title'])
slides = Slide.objects.filter(meeting=act.meeting).filter(slide_name=m.group(1)).filter(group_acronym_id=act.group_acronym_id)
if len(slides) == 1:
obj['link'] = self.base_url + slides[0].file_loc()

m = re.match("^agenda was uploaded$", act.activity)
if m:
obj['title'] = "agenda";
agendas = WgAgenda.objects.filter(meeting=act.meeting).filter(group_acronym_id=act.group_acronym_id)
if len(agendas) == 1:
dir = Proceeding.objects.get(meeting_num=act.meeting).dir_name
obj['link'] = self.base_url + dir + "/agenda/" + agendas[0].filename

if len(obj) > 0:
try:
act.irtf = False
obj['group_acronym'] = act.acronym()
except:
act.irtf = True
try:
obj['group_acronym'] = act.acronym()
except:
obj['group_acronym'] = "?"
obj['date'] = datetime.combine(act.act_date, time(int(act.act_time[0:2]), int(act.act_time[3:5]), int(act.act_time[6:8])))
obj['author'] = str(act.act_by)
objs.append(obj)

return objs

def get_object(self, bits):
obj = {}
obj['title'] = "This is the title";
return obj

def title(self, obj):
return "Meeting Materials Activity"

def item_link(self, item):
if 'link' in item:
return item['link']
else:
return ""

def item_pubdate(self, item):
return item['date']

def item_author_name(self, item):
return item['author']

def item_author_email(self, item):
return None;
20 changes: 20 additions & 0 deletions ietf/proceedings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,3 +469,23 @@ class Meta:
db_table = 'slides'
class Admin:
pass

class WgProceedingsActivities(models.Model, ResolveAcronym):
id = models.AutoField(primary_key=True)
group_acronym_id = models.IntegerField(null=True, blank=True)
group_acronym = models.ForeignKey(Acronym, raw_id_admin=True)

meeting = models.ForeignKey(Meeting, db_column='meeting_num')
activity = models.CharField(blank=True, maxlength=255)
act_date = models.DateField(null=True, blank=True)
act_time = models.CharField(blank=True, maxlength=100)
act_by = models.ForeignKey(PersonOrOrgInfo, db_column='act_by')
irtf = None

def __str__(self):
#return "IETF%d: %s slides (%s)" % (self.meeting_id, self.acronym(), self.activity)
return "this is WgProceedingsActivities.__str__"
class Meta:
db_table = 'wg_proceedings_activities'
class Admin:
pass
Loading

0 comments on commit 4506cb4

Please sign in to comment.