Merge Request #8

Merged
softwarepublico/colab!8
Created by Charles Oliveira

Username fix

Assignee: Sergio Oliveira
Milestone: None

Merged by Sergio Oliveira

Source branch has been removed
Commits (3)
2 participants
colab/accounts/forms.py
@@ -27,6 +27,11 @@ class SocialAccountField(forms.Field): @@ -27,6 +27,11 @@ class SocialAccountField(forms.Field):
27 27
28 28
29 class UserForm(forms.ModelForm): 29 class UserForm(forms.ModelForm):
  30 + username = forms.CharField(
  31 +
  32 + # Forces username to be lowercase always
  33 + widget=forms.TextInput(attrs={'style' : 'text-transform: lowercase;'}),
  34 + )
30 required = ('first_name', 'last_name', 'email', 'username') 35 required = ('first_name', 'last_name', 'email', 'username')
31 36
32 class Meta: 37 class Meta:
colab/accounts/models.py
@@ -49,6 +49,12 @@ class User(AbstractUser): @@ -49,6 +49,12 @@ class User(AbstractUser):
49 def update_subscription(self, email, lists): 49 def update_subscription(self, email, lists):
50 mailman.update_subscription(email, lists) 50 mailman.update_subscription(email, lists)
51 51
  52 + def save(self, *args, **kwargs):
  53 +
  54 + # Forces username to be lowercase always
  55 + self.username = self.username.lower()
  56 + super(User, self).save(*args, **kwargs)
  57 +
52 58
53 # We need to have `email` field set as unique but Django does not 59 # We need to have `email` field set as unique but Django does not
54 # support field overriding (at least not until 1.6). 60 # support field overriding (at least not until 1.6).
@@ -60,7 +66,7 @@ User._meta.get_field('username').help_text = _( @@ -60,7 +66,7 @@ User._meta.get_field('username').help_text = _(
60 u'./+/-/_ only.' 66 u'./+/-/_ only.'
61 ) 67 )
62 User._meta.get_field('username').validators[0] = validators.RegexValidator( 68 User._meta.get_field('username').validators[0] = validators.RegexValidator(
63 - r'^[\w.+-]+$', 69 + r'^\w+$',
64 _('Enter a valid username.'), 70 _('Enter a valid username.'),
65 'invalid' 71 'invalid'
66 ) 72 )
vagrant/centos.sh
@@ -54,5 +54,8 @@ fi @@ -54,5 +54,8 @@ fi
54 ### Create colab user in PostgreSQL 54 ### Create colab user in PostgreSQL
55 echo "CREATE USER colab WITH PASSWORD 'colab';" | sudo -u postgres -i psql 2> /dev/null || echo 55 echo "CREATE USER colab WITH PASSWORD 'colab';" | sudo -u postgres -i psql 2> /dev/null || echo
56 56
57 -#i## Create colab DB in PostgreSQL 57 +### Create colab DB in PostgreSQL
58 sudo -u postgres -i createdb --owner=colab colab 2> /dev/null | echo 58 sudo -u postgres -i createdb --owner=colab colab 2> /dev/null | echo
  59 +
  60 +### Forcing postgresql to start at boot
  61 +sudo chkconfig postgresql on