Skip to content

Commit 80d7ab9

Browse files
committed
Adding an "href" method to documents. It doesn't work for documents of type 'liai-att' or 'liaison', but it's a good start.
- Legacy-Id: 4721
1 parent 533dec8 commit 80d7ab9

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

ietf/doc/models.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ def get_file_path(self):
7575
else:
7676
raise NotImplemented
7777

78+
def href(self):
79+
try:
80+
format = settings.DOC_HREFS[self.type_id]
81+
except KeyError:
82+
if len(self.external_url):
83+
return self.external_url
84+
return None
85+
meeting = None
86+
if self.type_id in ("agenda", "minutes", "slides"):
87+
meeting = self.name.split("-")[1]
88+
return format.format(doc=self,meeting=meeting)
89+
7890
def set_state(self, state):
7991
"""Switch state type implicit in state to state. This just
8092
sets the state, doesn't log the change."""
@@ -173,7 +185,6 @@ def get_absolute_url(self):
173185
return urlreverse('doc_view', kwargs={ 'name': name }, urlconf="ietf.urls")
174186

175187

176-
177188
def file_tag(self):
178189
return u"<%s>" % self.filename_with_rev()
179190

ietf/settings.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,22 @@
208208
IESG_WG_EVALUATION_DIR = "/a/www/www6/iesg/evaluation"
209209
INTERNET_DRAFT_ARCHIVE_DIR = '/a/www/www6s/draft-archive'
210210

211+
# Ideally, more of these would be local -- but since we don't support
212+
# versions right now, we'll point to external websites
213+
DOC_HREFS = {
214+
"agenda": "/meeting/{meeting}/agenda/{doc.group.acronym}/",
215+
#"charter": "/doc/{doc.name}-{doc.rev}/",
216+
"charter": "http://www.ietf.org/charter/{doc.name}-{doc.rev}.txt",
217+
#"draft": "/doc/{doc.name}-{doc.rev}/",
218+
"draft": "http://tools.ietf.org/html/{doc.name}-{doc.rev}",
219+
# I can't figure out the liaison maze. Hopefully someone
220+
# who understands this better can take care of it.
221+
#"liai-att": None
222+
#"liaison": None
223+
"minutes": "http://www.ietf.org/proceedings/{meeting}/minutes/{doc.name}",
224+
"slides": "http://www.ietf.org/proceedings/{meeting}/slides/{doc.name}",
225+
}
226+
211227
# Override this in settings_local.py if needed
212228
CACHE_MIDDLEWARE_SECONDS = 300
213229
CACHE_MIDDLEWARE_KEY_PREFIX = ''

0 commit comments

Comments
 (0)