source: telemeta/models/system.py @ bfa68c2

cremcrem2devdev2diademsfeature/breadcrumbsfeature/ts-0.5feature/ts-0.5.4feature/writecacheformagenericinstru_searchlamlam2mapsv3mergenlivemultiproductionrelease/1.4.4sabiodsecurityserversocialstoragetelecastertest
Last change on this file since bfa68c2 was bfa68c2, checked in by yomguy <yomguy@…>, 2 years ago

add init password

  • Property mode set to 100644
File size: 4.8 KB
Line 
1# -*- coding: utf-8 -*-
2# Copyright (C) 2007-2010 Samalyse SARL
3# Copyright (C) 2010-2011 Parisson SARL
4
5# This software is a computer program whose purpose is to backup, analyse,
6# transcode and stream any audio content with its metadata over a web frontend.
7
8# This software is governed by the CeCILL  license under French law and
9# abiding by the rules of distribution of free software.  You can  use,
10# modify and/ or redistribute the software under the terms of the CeCILL
11# license as circulated by CEA, CNRS and INRIA at the following URL
12# "http://www.cecill.info".
13
14# As a counterpart to the access to the source code and  rights to copy,
15# modify and redistribute granted by the license, users are provided only
16# with a limited warranty  and the software's author,  the holder of the
17# economic rights,  and the successive licensors  have only  limited
18# liability.
19
20# In this respect, the user's attention is drawn to the risks associated
21# with loading,  using,  modifying and/or developing or reproducing the
22# software by the user in light of its specific status of free software,
23# that may mean  that it is complicated to manipulate,  and  that  also
24# therefore means  that it is reserved for developers  and  experienced
25# professionals having in-depth computer knowledge. Users are therefore
26# encouraged to load and test the software's suitability as regards their
27# requirements in conditions enabling the security of their systems and/or
28# data to be ensured and,  more generally, to use and operate it in the
29# same conditions as regards security.
30
31# The fact that you are presently reading this means that you have had
32# knowledge of the CeCILL license and that you accept its terms.
33#
34# Authors: Olivier Guilyardi <olivier@samalyse.com>
35#          David LIPSZYC <davidlipszyc@gmail.com>
36#          Guillaume Pellerin <yomguy@parisson.com>
37
38from django.contrib.auth.models import User
39from telemeta.models.core import *
40from django.core.exceptions import ObjectDoesNotExist
41from django.utils.translation import ugettext_lazy as _
42import django.db.models as models
43from django.forms import ModelForm
44
45
46class Revision(ModelCore):
47    "Revision made by user"
48
49    ELEMENT_TYPE_CHOICES = (('collection', 'collection'), ('item', 'item'), ('part', 'part'), ('marker', 'marker'), ('media', 'media'), ('fonds', 'fonds'), ('corpus', 'corpus'))
50    CHANGE_TYPE_CHOICES  = (('import', 'import'), ('create', 'create'), ('update', 'update'), ('delete','delete'))
51
52    element_type         = CharField(_('element type'), choices=ELEMENT_TYPE_CHOICES, max_length=16, required=True)
53    element_id           = IntegerField(_('element identifier'), required=True)
54    change_type          = CharField(_('modification type'), choices=CHANGE_TYPE_CHOICES, max_length=16, required=True)
55    time                 = DateTimeField(_('time'), auto_now_add=True)
56    user                 = ForeignKey(User, db_column='username', related_name="revisions", verbose_name=_('user'))
57
58    @classmethod
59    def touch(cls, element, user):
60        "Create or update a revision"
61        revision = cls(element_type=element.element_type, element_id=element.pk,
62                       user=user, change_type='create')
63        if element.pk:
64            try:
65                element.__class__.objects.get(pk=element.pk)
66            except ObjectDoesNotExist:
67                pass
68            else:
69                revision.change_type = 'update'
70
71        revision.save()
72        return revision
73
74    def __str__(self):
75        return str(self.time) + ' : ' + self.element_type + ' : ' + str(self.element_id)
76
77    class Meta(MetaCore):
78        db_table = 'revisions'
79
80
81class UserProfile(models.Model):
82    "User profile extension"
83
84    user            = ForeignKey(User, unique=True, required=True)
85    institution     = CharField(_('Institution'))
86    function        = CharField(_('Function'))
87    address         = TextField(_('Address'))
88    telephone       = CharField(_('Telephone'))
89    expiration_date = DateField(_('Expiration_date'))
90    init_password   = BooleanField(_('Password initialization'))
91
92    class Meta(MetaCore):
93        db_table = 'profiles'
94
95
96class Criteria(ModelCore):
97    "Search criteria"
98
99    element_type = 'search_criteria'
100
101    key = CharField(_('key'), required=True)
102    value = CharField(_('value'), required=True)
103
104    class Meta(MetaCore):
105        db_table = 'search_criteria'
106
107
108class Search(ModelCore):
109    "Keywork search"
110
111    element_type = 'search'
112
113    username = ForeignKey(User, related_name="searches", db_column="username")
114    date = DateTimeField(_('date'), auto_now_add=True)
115    description = CharField(_('Description'))
116    criteria = models.ManyToManyField(Criteria, related_name="search",
117                                      verbose_name=_('criteria'), blank=True, null=True)
118
119    class Meta(MetaCore):
120        db_table = 'searches'
121        ordering = ['-date']
122
123    def __unicode__(self):
124        return self.keywords
125
126
127
Note: See TracBrowser for help on using the repository browser.