diff options
Diffstat (limited to 'archaeological_files/models.py')
-rw-r--r-- | archaeological_files/models.py | 44 |
1 files changed, 3 insertions, 41 deletions
diff --git a/archaeological_files/models.py b/archaeological_files/models.py index a649ceac1..4483e6401 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -30,7 +30,7 @@ from ishtar_common.utils import cached_label_changed, get_cache from ishtar_common.models import GeneralType, BaseHistorizedItem, \ HistoricalRecords, OwnPerms, Person, Organization, Department, Town, \ - Dashboard, IshtarUser, ValueGetter, ShortMenuItem + Dashboard, DashboardFormItem, IshtarUser, ValueGetter, ShortMenuItem class FileType(GeneralType): class Meta: @@ -61,7 +61,8 @@ if settings.COUNTRY == 'fr': verbose_name_plural = u"Types Saisine" ordering = ('label',) -class File(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem): +class File(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, + DashboardFormItem): TABLE_COLS = ['numeric_reference', 'year', 'internal_reference', 'file_type', 'saisine_type', 'towns', ] year = models.IntegerField(_(u"Year"), @@ -229,45 +230,6 @@ class File(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem): owns = super(File, cls).get_owns(user) return sorted(owns.all(), key=lambda x:x.cached_label) - @classmethod - def get_periods(cls, slice='month', fltr={}, date_source='creation'): - date_var = date_source + '_date' - q = cls.objects.filter(**{date_var+'__isnull':False}) - if fltr: - q = q.filter(**fltr) - if slice == 'year': - return [res[date_var].year for res in list(q.values(date_var - ).annotate(Count("id")).order_by())] - elif slice == 'month': - return [(res[date_var].year, res[date_var].month) - for res in list(q.values(date_var - ).annotate(Count("id")).order_by())] - return [] - - @classmethod - def get_by_year(cls, year, fltr={}, date_source='creation'): - date_var = date_source + '_date' - q = cls.objects.filter(**{date_var+'__isnull':False}) - if fltr: - q = q.filter(**fltr) - return q.filter(**{date_var+'__year':year}) - - @classmethod - def get_by_month(cls, year, month, fltr={}, date_source='creation'): - date_var = date_source + '_date' - q = cls.objects.filter(**{date_var+'__isnull':False}) - if fltr: - q = q.filter(**fltr) - q = q.filter(**{date_var+'__year':year, date_var+'__month':month}) - return q - - @classmethod - def get_total_number(cls, fltr={}): - q = cls.objects - if fltr: - q = q.filter(**fltr) - return q.count() - def get_values(self, prefix=''): values = super(File, self).get_values(prefix=prefix) values['adminact_associated_file_towns_count'] = unicode( |