Commit 6efc3b8fc879607605cd7e8bf325ce29211420df
Exists in
master
and in
39 other branches
Merge branch 'username-fix' into 'master'
Username fix
Showing
3 changed files
with
16 additions
and
2 deletions
Show diff stats
colab/accounts/forms.py
| ... | ... | @@ -27,6 +27,11 @@ class SocialAccountField(forms.Field): |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 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 | 35 | required = ('first_name', 'last_name', 'email', 'username') |
| 31 | 36 | |
| 32 | 37 | class Meta: | ... | ... |
colab/accounts/models.py
| ... | ... | @@ -49,6 +49,12 @@ class User(AbstractUser): |
| 49 | 49 | def update_subscription(self, email, lists): |
| 50 | 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 | 59 | # We need to have `email` field set as unique but Django does not |
| 54 | 60 | # support field overriding (at least not until 1.6). |
| ... | ... | @@ -60,7 +66,7 @@ User._meta.get_field('username').help_text = _( |
| 60 | 66 | u'./+/-/_ only.' |
| 61 | 67 | ) |
| 62 | 68 | User._meta.get_field('username').validators[0] = validators.RegexValidator( |
| 63 | - r'^[\w.+-]+$', | |
| 69 | + r'^\w+$', | |
| 64 | 70 | _('Enter a valid username.'), |
| 65 | 71 | 'invalid' |
| 66 | 72 | ) | ... | ... |
vagrant/centos.sh
| ... | ... | @@ -54,5 +54,8 @@ fi |
| 54 | 54 | ### Create colab user in PostgreSQL |
| 55 | 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 | 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 | ... | ... |