summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Mihai <smihai@entrouvert.com>2015-04-24 12:28:13 (GMT)
committerSerghei Mihai <smihai@entrouvert.com>2015-04-24 16:58:29 (GMT)
commit51ba134ec8a17687d9a920ce068afbdc15755e52 (patch)
tree9c28f4c57ab5907ae6d5f217ddc54e377ca84ee7
parent17b0cd9a9985e88f010790fa369809eee56f9249 (diff)
downloadu-auth-51ba134ec8a17687d9a920ce068afbdc15755e52.zip
u-auth-51ba134ec8a17687d9a920ce068afbdc15755e52.tar.gz
u-auth-51ba134ec8a17687d9a920ce068afbdc15755e52.tar.bz2
replace TemporaryAccount model by LocalAccount
-rw-r--r--uauth/organization/migrations/0002_auto_20150424_1858.py43
-rw-r--r--uauth/organization/models.py32
2 files changed, 71 insertions, 4 deletions
diff --git a/uauth/organization/migrations/0002_auto_20150424_1858.py b/uauth/organization/migrations/0002_auto_20150424_1858.py
new file mode 100644
index 0000000..ed3b5a5
--- /dev/null
+++ b/uauth/organization/migrations/0002_auto_20150424_1858.py
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('organization', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='LocalAccount',
+ fields=[
+ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+ ('username', models.CharField(max_length=128, verbose_name='Username')),
+ ('first_name', models.CharField(max_length=64, null=True, verbose_name='First name', blank=True)),
+ ('last_name', models.CharField(max_length=64, null=True, verbose_name='Last name', blank=True)),
+ ('creation_date', models.DateTimeField(auto_now_add=True)),
+ ('expiration_date', models.DateTimeField(null=True, blank=True)),
+ ('password', models.CharField(help_text='Leave empty to auto-generate', max_length=128, verbose_name='Password', blank=True)),
+ ('description', models.TextField(null=True, verbose_name='Description', blank=True)),
+ ('active', models.BooleanField(default=True, verbose_name='Active')),
+ ('organization', models.ForeignKey(to='organization.Organization')),
+ ],
+ options={
+ },
+ bases=(models.Model,),
+ ),
+ migrations.RemoveField(
+ model_name='temporaryaccount',
+ name='organization',
+ ),
+ migrations.DeleteModel(
+ name='TemporaryAccount',
+ ),
+ migrations.AlterUniqueTogether(
+ name='localaccount',
+ unique_together=set([('organization', 'username')]),
+ ),
+ ]
diff --git a/uauth/organization/models.py b/uauth/organization/models.py
index d1e08c1..86d5cba 100644
--- a/uauth/organization/models.py
+++ b/uauth/organization/models.py
@@ -1,5 +1,9 @@
from django.db import models
from django.utils.translation import ugettext as _
+from django.utils.timezone import make_aware, get_current_timezone
+
+from datetime import datetime
+
HOTSPOT_CHOICES = (
('pfsense', 'pfSense'),
@@ -26,9 +30,29 @@ class OrganizationMember(models.Model):
entity_id = models.CharField(max_length=256)
-class TemporaryAccount(models.Model):
+class LocalAccount(models.Model):
organization = models.ForeignKey(Organization)
username = models.CharField(_('Username'), max_length=128)
- creation_date = models.DateTimeField(auto_now_add=True)
- password = models.CharField(_('Password'), max_length=128)
- voucher = models.CharField(_('Voucher'), max_length=128)
+ first_name = models.CharField(_('First name'), max_length=64,
+ null=True, blank=True)
+ last_name = models.CharField(_('Last name'), max_length=64,
+ null=True, blank=True)
+ creation_date = models.DateTimeField(auto_now_add=True, blank=True)
+ expiration_date = models.DateTimeField(null=True, blank=True)
+ password = models.CharField(_('Password'), max_length=128, blank=True,
+ help_text=_('Leave empty to auto-generate'))
+ description = models.TextField(_('Description'), null=True,
+ blank=True)
+ active = models.BooleanField(_('Active'), default=True)
+
+ class Meta:
+ unique_together = ('organization', 'username')
+
+ def expired(self):
+ if self.expiration_date:
+ return self.expiration_date < make_aware(datetime.now(),
+ get_current_timezone())
+ return False
+
+ def get_fullname(self):
+ return '%s %s' % (self.first_name, self.last_name)