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

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
from distutils.util import strtobool
from operator import attrgetter
from itertools import chain
import re
# core django imports
from django.http import HttpResponseForbidden, HttpResponseRedirect, Http404
from django.views.generic import CreateView, ListView, DetailView, FormView, DeleteView
......@@ -94,6 +95,11 @@ def create_email(text_path, html_path, subject, to, context):
return msg
def no_nums(name):
no_numbers = re.sub('[0-9]', '', name)
return no_numbers
# details about the student
class DetailStudent(LoginRequiredMixin, DetailView):
model = Student
......@@ -304,8 +310,8 @@ class UpdateStudent(LoginRequiredMixin, FormValidMessageMixin, FormView):
except:
pass
me.user.first_name = form.data['first_name']
me.user.last_name = form.data['last_name']
me.user.first_name = no_nums(form.data['first_name'])
me.user.last_name = no_nums(form.data['last_name'])
me.gender = form.data.getlist('gender')
me.show_gender = strtobool(form.data.get('show_gender', 'False'))
me.privacy = form.data['privacy']
......
......@@ -12,7 +12,7 @@ from braces.views import LoginRequiredMixin
from ratelimit.decorators import ratelimit
# imports from your apps
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 .forms import (WelcomeNameForm, WelcomeMajorForm,
WelcomePrivacyForm, WelcomeSocialForm)
......@@ -79,8 +79,8 @@ class WelcomeName(LoginRequiredMixin, FormView):
def form_valid(self, form):
me = Student.objects.get(user=self.request.user)
me.user.first_name = form.data['first_name']
me.user.last_name = form.data['last_name']
me.user.first_name = no_nums(form.data['first_name'])
me.user.last_name = no_nums(form.data['last_name'])
me.gender = form.data.getlist('gender')
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