defget_next_year(self,date):"""Get the next valid year."""return_get_next_prev(self,date,is_previous=False,period='year')
Get the previous valid year.
48
49
50
defget_previous_year(self,date):"""Get the previous valid year."""return_get_next_prev(self,date,is_previous=True,period='year')
Возвращает год, для которого это представление должно отображать данные.
31
32
33
34
35
36
37
38
39
40
41
42
defget_year(self):"""Return the year for which this view should display data."""year=self.yearifyearisNone:try:year=self.kwargs['year']exceptKeyError:try:year=self.request.GET['year']exceptKeyError:raiseHttp404(_("No year specified"))returnyear
Получает строку в формате года в синтаксисе strptime, которая будет использоваться для анализа года по переменным URL.
24
25
26
27
28
29
defget_year_format(self):""" Get a year format string in strptime syntax to be used to parse the year from url variables. """returnself.year_format
Возвращает дату начала текущего интервала.
63
64
65
def_get_current_year(self,date):"""Return the start date of the current interval."""returndate.replace(month=1,day=1)
Возвращает дату начала следующего интервала.
Интервал определяется датой начала <= дата элемента < следующая дата начала.
52
53
54
55
56
57
58
59
60
def_get_next_year(self,date):""" Return the start date of the next interval. The interval is defined by start date <= item date < next start date. """try:returndate.replace(year=date.year+1,month=1,day=1)exceptValueError:raiseHttp404(_("Date out of range"))