Commit 2e3b0b9f authored by Daniel W Bond's avatar Daniel W Bond
Browse files

whoops, forgot to commit this before closing the issue-- strip numbers [0-9] from student's names

parent 4567b3b5
...@@ -4,6 +4,7 @@ import random ...@@ -4,6 +4,7 @@ import random
from distutils.util import strtobool from distutils.util import strtobool
from operator import attrgetter from operator import attrgetter
from itertools import chain from itertools import chain
import re
# core django imports # core django imports
from django.http import HttpResponseForbidden, HttpResponseRedirect, Http404 from django.http import HttpResponseForbidden, HttpResponseRedirect, Http404
from django.views.generic import CreateView, ListView, DetailView, FormView, DeleteView from django.views.generic import CreateView, ListView, DetailView, FormView, DeleteView
...@@ -94,6 +95,11 @@ def create_email(text_path, html_path, subject, to, context): ...@@ -94,6 +95,11 @@ def create_email(text_path, html_path, subject, to, context):
return msg return msg
def no_nums(name):
no_numbers = re.sub('[0-9]', '', name)
return no_numbers
# details about the student # details about the student
class DetailStudent(LoginRequiredMixin, DetailView): class DetailStudent(LoginRequiredMixin, DetailView):
model = Student model = Student
...@@ -304,8 +310,8 @@ class UpdateStudent(LoginRequiredMixin, FormValidMessageMixin, FormView): ...@@ -304,8 +310,8 @@ class UpdateStudent(LoginRequiredMixin, FormValidMessageMixin, FormView):
except: except:
pass pass
me.user.first_name = form.data['first_name'] me.user.first_name = no_nums(form.data['first_name'])
me.user.last_name = form.data['last_name'] me.user.last_name = no_nums(form.data['last_name'])
me.gender = form.data.getlist('gender') me.gender = form.data.getlist('gender')
me.show_gender = strtobool(form.data.get('show_gender', 'False')) me.show_gender = strtobool(form.data.get('show_gender', 'False'))
me.privacy = form.data['privacy'] me.privacy = form.data['privacy']
......
...@@ -12,7 +12,7 @@ from braces.views import LoginRequiredMixin ...@@ -12,7 +12,7 @@ from braces.views import LoginRequiredMixin
from ratelimit.decorators import ratelimit from ratelimit.decorators import ratelimit
# imports from your apps # imports from your apps
from accounts.models import Student, Confirmation, Major from accounts.models import Student, Confirmation, Major
from accounts.views import create_email from accounts.views import create_email, no_nums
from housing.models import Room from housing.models import Room
from .forms import (WelcomeNameForm, WelcomeMajorForm, from .forms import (WelcomeNameForm, WelcomeMajorForm,
WelcomePrivacyForm, WelcomeSocialForm) WelcomePrivacyForm, WelcomeSocialForm)
...@@ -79,8 +79,8 @@ class WelcomeName(LoginRequiredMixin, FormView): ...@@ -79,8 +79,8 @@ class WelcomeName(LoginRequiredMixin, FormView):
def form_valid(self, form): def form_valid(self, form):
me = Student.objects.get(user=self.request.user) me = Student.objects.get(user=self.request.user)
me.user.first_name = form.data['first_name'] me.user.first_name = no_nums(form.data['first_name'])
me.user.last_name = form.data['last_name'] me.user.last_name = no_nums(form.data['last_name'])
me.gender = form.data.getlist('gender') me.gender = form.data.getlist('gender')
me.show_gender = strtobool(form.data.get('show_gender', 'False')) me.show_gender = strtobool(form.data.get('show_gender', 'False'))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment