Skip to content

Commit cbbeb41

Browse files
committed
Issue 2 Patch
1 parent b2b4935 commit cbbeb41

File tree

6 files changed

+53
-5
lines changed

6 files changed

+53
-5
lines changed

Diff for: CheckMate2017-master/checkmate2017/db.sqlite3

-35 KB
Binary file not shown.

Diff for: CheckMate2017-master/checkmate2017/mainapp/admin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from django.contrib import admin
2-
from .models import Answer,UserProfile, Question, Building, GameSwitch
2+
from .models import Answer,UserProfile, Question, Building, GameSwitch, TeamProfile
33
# Register your models here.
44

55
admin.site.register(UserProfile)
66
admin.site.register(Question)
77
admin.site.register(Building)
88
admin.site.register(GameSwitch)
99
admin.site.register(Answer)
10-
10+
admin.site.register(TeamProfile)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.4 on 2017-09-17 17:10
3+
from __future__ import unicode_literals
4+
5+
import django.core.validators
6+
from django.db import migrations, models
7+
import re
8+
9+
10+
class Migration(migrations.Migration):
11+
12+
dependencies = [
13+
('mainapp', '0045_auto_20170913_2253'),
14+
]
15+
16+
operations = [
17+
migrations.CreateModel(
18+
name='TeamProfile',
19+
fields=[
20+
('teamname', models.CharField(max_length=200)),
21+
('idno1', models.CharField(max_length=20, primary_key=True, serialize=False, validators=[django.core.validators.RegexValidator(re.compile('^201[0-9]{1}[0-9A-Z]{4}[0-9]{4}P$', 32), code='invalid!', message='Enter your valid BITS-mail')])),
22+
],
23+
),
24+
]

Diff for: CheckMate2017-master/checkmate2017/mainapp/models.py

+8
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,11 @@ class GameSwitch(models.Model):
5656

5757
def __str__(self):
5858
return self.name
59+
60+
class TeamProfile(models.Model):
61+
teamname = models.CharField(max_length=200)
62+
idno1 = models.CharField(max_length=20,primary_key=True, validators=[
63+
validators.RegexValidator(re.compile('^201[0-9]{1}[0-9A-Z]{4}[0-9]{4}P$'), message='Enter your valid BITS-mail', code='invalid!')])
64+
65+
def __str__(self):
66+
return self.teamname

Diff for: CheckMate2017-master/checkmate2017/mainapp/views.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django.core.urlresolvers import reverse
22
from django.shortcuts import render
33
from django.http import HttpResponse, Http404 ,HttpResponseForbidden
4-
from .models import UserProfile, GameSwitch, Building, Question, Answer
4+
from .models import UserProfile, GameSwitch, Building, Question, Answer, TeamProfile
55
from django.shortcuts import redirect, render_to_response
66
from django.contrib.auth import authenticate, login, logout as django_logout
77
from django.contrib import auth
@@ -36,6 +36,21 @@ def register(request):
3636
print (form)
3737
print("reached1")
3838
data = form.cleaned_data
39+
### Patch for Issue 2
40+
### TeamProfile object created here.
41+
team = TeamProfile()
42+
team.teamname = data['teamname1']
43+
team.idno1 = data['idno1']
44+
try:
45+
t = TeamProfile.objects.get(pk=data['idno1'])
46+
resp = {
47+
'status': 'error',
48+
'msg': 'BITS ID 1 has already been used to create a Team! '
49+
}
50+
return HttpResponse(json.dumps(resp), content_type="application/json", status=500)
51+
except Exception:
52+
team.save()
53+
### Patch Ends
3954
u = User()
4055
u.username = data['teamname1']
4156
u.set_password(data['password1'])
@@ -48,6 +63,7 @@ def register(request):
4863
'msg': 'Team name already registered or other conflicting entries'
4964
}
5065
return HttpResponse(json.dumps(resp), content_type = "application/json",status=500)
66+
5167
up = UserProfile()
5268
up.user = u
5369
up.teamname = data['teamname1']
@@ -90,7 +106,7 @@ def register(request):
90106
print("reached3")
91107
return HttpResponse(json.dumps(r),content_type="application/json",status=301)
92108
else:
93-
return HttpResponse('You have already registered once from this pc! Contact neartest ACM invigilator')
109+
return HttpResponse('You have already registered once from this pc! Contact nearest ACM invigilator')
94110

95111

96112
def instructions(request):

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Some minor issues that were faced:( Has been assigned as small issues)
2121

2222
2> IP based checks to be improved
2323

24-
3> ID across teams
24+
3> ID across teams: Has been resolved. For further information, refer to Issue 2.
2525

2626

2727
To use the django project, create a virtual environment activate it. use pip install -r requirements to install required packages then python manage.py makemigrations python manange.py migrate python mange.py runserver

0 commit comments

Comments
 (0)