Commit 4135c91b by Dányi Bence

school: trim whitespace on NETPUNK codes

parent 8614fc2a
...@@ -183,7 +183,7 @@ def group_new(request): ...@@ -183,7 +183,7 @@ def group_new(request):
members_list = re.split('\r?\n', request.POST['members']) members_list = re.split('\r?\n', request.POST['members'])
members = [] members = []
for member in members_list: for member in members_list:
if re.match('^[a-zA-Z][a-zA-Z0-9]{5}$', member) == None: if re.match('^[a-zA-Z][a-zA-Z0-9]{5}$', member.strip()) == None:
messages.error(request, _('Invalid NEPTUN code found.')) messages.error(request, _('Invalid NEPTUN code found.'))
return redirect('/') return redirect('/')
person, created = Person.objects.get_or_create(code=member) person, created = Person.objects.get_or_create(code=member)
...@@ -203,7 +203,7 @@ def group_new(request): ...@@ -203,7 +203,7 @@ def group_new(request):
def group_ajax_add_new_member(request, gid): def group_ajax_add_new_member(request, gid):
group = get_object_or_404(Group, id=gid) group = get_object_or_404(Group, id=gid)
member = request.POST['neptun'] member = request.POST['neptun']
if re.match('^[a-zA-Z][a-zA-Z0-9]{5}$', member) == None: if re.match('^[a-zA-Z][a-zA-Z0-9]{5}$', member.strip()) == None:
status = json.dumps({'status': 'Error'}) status = json.dumps({'status': 'Error'})
messages.error(request, _('Invalid NEPTUN code')) messages.error(request, _('Invalid NEPTUN code'))
return HttpResponse(status) return HttpResponse(status)
......
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 sign in to comment