Skip to content

Commit c7c4679

Browse files
committed
Merged [4721] from adam@nostrum.com:
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: 4726 Note: SVN reference [4721] has been migrated to Git commit 80d7ab9
2 parents 77de554 + 80d7ab9 commit c7c4679

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
@@ -210,6 +210,22 @@
210210
IESG_WG_EVALUATION_DIR = "/a/www/www6/iesg/evaluation"
211211
INTERNET_DRAFT_ARCHIVE_DIR = '/a/www/www6s/draft-archive'
212212

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

0 commit comments

Comments
 (0)