source: telemeta/models/system.py @ 3f8407d

cremcrem2devdev2diademsdj1.6feature/breadcrumbsfeature/ts-0.5feature/ts-0.5.4feature/writecacheformagenericinstru_searchlamlam2mapsv3mergenlivemultiproductionrelease/1.4.4sabiodsecurityserversocialstoragetelecastertestvideo
Last change on this file since 3f8407d was 3f8407d, checked in by yomguy <yomguy@…>, 4 years ago

hide some user fields for basic users

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