From 196d96331aa2a4eded9b6dced5927380025abc00 Mon Sep 17 00:00:00 2001 From: Zambom Date: Tue, 20 Dec 2016 18:01:07 -0200 Subject: [PATCH] Adding last_update field in users --- users/forms.py | 3 --- users/migrations/0002_auto_20161220_1700.py | 24 ++++++++++++++++++++++++ users/models.py | 8 +------- 3 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 users/migrations/0002_auto_20161220_1700.py diff --git a/users/forms.py b/users/forms.py index 196d5fd..7ec8399 100644 --- a/users/forms.py +++ b/users/forms.py @@ -40,9 +40,6 @@ class RegisterUserForm(ValidationRegister): self.instance.set_password(self.cleaned_data['password']) self.instance.save() - - if self.instance.type_profile == 2: - assign_role(self.instance, 'student') return self.instance diff --git a/users/migrations/0002_auto_20161220_1700.py b/users/migrations/0002_auto_20161220_1700.py new file mode 100644 index 0000000..0593264 --- /dev/null +++ b/users/migrations/0002_auto_20161220_1700.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2016-12-20 20:00 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='user', + name='type_profile', + ), + migrations.AddField( + model_name='user', + name='last_update', + field=models.DateTimeField(auto_now=True, verbose_name='Last Update'), + ), + ] diff --git a/users/models.py b/users/models.py index 21ec2ea..951ca82 100644 --- a/users/models.py +++ b/users/models.py @@ -20,8 +20,8 @@ class User(AbstractBaseUser, PermissionsMixin): social_name = models.CharField(_('Social Name'), max_length = 100, blank = True, null = True) description = models.TextField(_('Description'), blank = True) image = models.ImageField(verbose_name = _('Photo'), null=True, blank = True, upload_to = 'users/') - type_profile = models.IntegerField(_('Type'), null = True, blank = True, choices = ((1, _('Professor')), (2, _('Student')), (3, _('Coordinator')))) date_created = models.DateTimeField(_('Create Date'), auto_now_add = True) + last_update = models.DateTimeField(_('Last Update'), auto_now = True) show_email = models.IntegerField(_('Show email?'), null = True, choices = ((1, _('Allow everyone to see my address')), (2, _('Only classmates can see my address')), (3, _('Nobody can see my address')))) is_staff = models.BooleanField(_('Administrator'), default = False) is_active = models.BooleanField(_('Active'), default = True) @@ -38,12 +38,6 @@ class User(AbstractBaseUser, PermissionsMixin): def __str__(self): return self.social_name or self.username - def save(self, *args, **kwargs): - if not self.is_staff and self.type_profile is None: - self.type_profile = 2 - - super(User, self).save(*args, **kwargs) - @property def image_url(self): if self.image and hasattr(self.image, 'url'): -- libgit2 0.21.2