forked from adamlaska/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
62 lines (48 loc) · 1.92 KB
/
models.py
File metadata and controls
62 lines (48 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright The IETF Trust 2013-2020, All Rights Reserved
# -*- coding: utf-8 -*-
import os
from django.conf import settings
from django.db import models
from ietf.meeting.models import Meeting
class InterimManager(models.Manager):
'''A custom manager to limit objects to type=interim'''
def get_queryset(self):
return super(InterimManager, self).get_queryset().filter(type='interim')
class InterimMeeting(Meeting):
'''
This class is a proxy of Meeting. It's purpose is to provide extra methods that are
useful for an interim meeting, to help in templates. Most information is derived from
the session associated with this meeting. We are assuming there is only one.
'''
class Meta:
proxy = True
objects = InterimManager()
def group(self):
return self.session_set.all()[0].group
def agenda(self): # pylint: disable=method-hidden
session = self.session_set.all()[0]
agendas = session.materials.exclude(states__slug='deleted').filter(type='agenda')
if agendas:
return agendas[0]
else:
return None
def minutes(self):
session = self.session_set.all()[0]
minutes = session.materials.exclude(states__slug='deleted').filter(type='minutes')
if minutes:
return minutes[0]
else:
return None
def get_proceedings_path(self, group=None):
return os.path.join(self.get_materials_path(),'proceedings.html')
def get_proceedings_url(self, group=None):
'''
If the proceedings file doesn't exist return empty string. For use in templates.
'''
if os.path.exists(self.get_proceedings_path()):
url = "%sproceedings/%s/proceedings.html" % (
settings.IETF_HOST_URL,
self.number)
return url
else:
return ''