source: telemeta/models/system.py @ 7d337e4

cremcrem2crem3devdev2diademsdj1.6feature/breadcrumbsfeature/ts-0.5feature/ts-0.5.4feature/writecacheformagenericinstru_searchlamlam2mapsv3mergenlivemultiprobproductionrelease/1.4.4sabiodsearchsecurityserversocialstoragetelecastertestvideo
Last change on this file since 7d337e4 was 7d337e4, checked in by yomguy <yomguy@…>, 4 years ago

update sandbox example (with sqlite3), cleanup, go to 0.9.8

  • Property mode set to 100644
File size: 3.9 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
43from django.forms import ModelForm
44
45
46class Revision(ModelCore):
47    "Revision made by user"
48    ELEMENT_TYPE_CHOICES = (('collection', 'collection'), ('item', 'item'), ('part', 'part'), ('marker', 'marker'))
49    CHANGE_TYPE_CHOICES  = (('import', 'import'), ('create', 'create'), ('update', 'update'), ('delete','delete'))
50
51    element_type         = CharField(_('element type'), choices=ELEMENT_TYPE_CHOICES, max_length=16, required=True)
52    element_id           = IntegerField(_('element identifier'), required=True)
53    change_type          = CharField(_('modification type'), choices=CHANGE_TYPE_CHOICES, max_length=16, required=True)
54    time                 = DateTimeField(_('time'), auto_now_add=True)
55    user                 = ForeignKey(User, db_column='username', related_name="revisions", verbose_name=_('user'))
56
57    @classmethod
58    def touch(cls, element, user):   
59        "Create or update a revision"
60        revision = cls(element_type=element.element_type, element_id=element.pk, 
61                       user=user, change_type='create')
62        if element.pk:
63            try: 
64                element.__class__.objects.get(pk=element.pk)
65            except ObjectDoesNotExist:
66                pass
67            else:
68                revision.change_type = 'update'
69
70        revision.save()
71        return revision
72
73    class Meta(MetaCore):
74        db_table = 'revisions'
75
76
77class UserProfile(django.db.models.Model):
78    "User profile extension"
79   
80    user            = ForeignKey(User, unique=True, required=True)
81    institution     = CharField(_('Institution'))
82    function        = CharField(_('Function'))
83    address         = TextField(_('Address'))
84    telephone       = CharField(_('Telephone'))
85    expiration_date = DateField(_('Expiration_date'))
86   
87    class Meta(MetaCore):
88        db_table = 'profiles'
89
90class UserProfileForm(ModelForm):
91    class Meta:
92        model = UserProfile
Note: See TracBrowser for help on using the repository browser.