SFA = Validation of Slices add user to slice & Update User keys, email and other...
[myslice.git] / portal / models.py
1 # -*- coding: utf-8 -*-
2 #
3 # portal/models.py: models for the portal application
4 # This file is part of the Manifold project.
5 #
6 # Authors:
7 #   Jordan AugĂ© <jordan.auge@lip6.fr>
8 # Copyright 2013, UPMC Sorbonne UniversitĂ©s / LIP6
9 #
10 # This program is free software; you can redistribute it and/or modify it under
11 # the terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 3, or (at your option) any later version.
13
14 # This program is distributed in the hope that it will be useful, but WITHOUT
15 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
17 # details.
18
19 # You should have received a copy of the GNU General Public License along with
20 # this program; see the file COPYING.  If not, write to the Free Software
21 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 import datetime
24 import hashlib
25 import random
26 import re
27
28 from django.conf              import settings
29 from django.core.mail         import send_mail
30 from django.db                import models
31 from django.db                import transaction
32 from django.utils.translation import ugettext_lazy as _
33 from django.template.loader   import render_to_string
34
35 #from django.core.validators import validate_email
36
37 try:
38     from django.contrib.auth import get_user_model
39     User = get_user_model()
40 except ImportError:
41     from django.contrib.auth.models import User
42
43 try:
44     from django.utils.timezone import now as datetime_now
45 except ImportError:
46     datetime_now = datetime.datetime.now
47
48 SHA1_RE = re.compile('^[a-f0-9]{40}$')
49
50 # Create your models here.
51
52 class Institution(models.Model):
53     name = models.TextField()
54     # list of associated email domains 
55
56 class PendingUser(models.Model):
57     # NOTE We might consider migrating the fields to CharField, which would
58     # simplify form creation in forms.py
59     first_name    = models.TextField()
60     last_name     = models.TextField()
61     email         = models.EmailField() #validators=[validate_email])
62     password      = models.TextField()
63     keypair       = models.TextField()
64     authority_hrn = models.TextField()
65     login         = models.TextField()
66     pi            = models.TextField()
67     created       = models.DateTimeField(auto_now_add = True)
68     # models.ForeignKey(Institution)
69
70 class PendingAuthority(models.Model):
71     site_name             = models.TextField()
72     site_authority        = models.TextField() 
73     site_abbreviated_name = models.TextField()
74     site_url              = models.TextField()
75     site_latitude         = models.TextField()
76     site_longitude        = models.TextField()
77     address_line1         = models.TextField()
78     address_line2         = models.TextField()
79     address_line3         = models.TextField()
80     address_city          = models.TextField()
81     address_postalcode    = models.TextField()
82     address_state         = models.TextField()
83     address_country       = models.TextField()
84     # parent authority of the requested authority
85     authority_hrn         = models.TextField()
86     created               = models.DateTimeField(auto_now_add = True)
87  
88 class PendingSlice(models.Model):
89     slice_name      = models.TextField()
90     user_hrn        = models.TextField()
91     authority_hrn   = models.TextField(null=True)
92     number_of_nodes = models.TextField(default=0)
93     type_of_nodes   = models.TextField(default='NA')
94     purpose         = models.TextField(default='NA')
95     created         = models.DateTimeField(auto_now_add = True)