Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
General_Allocation_Portal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
codemafia
General_Allocation_Portal
Commits
a8ce99f2
Commit
a8ce99f2
authored
Oct 26, 2017
by
amanjain2898@gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
validators and corner-cases
parent
33dc204e
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
150 additions
and
20 deletions
+150
-20
project/allocation/__pycache__/urls.cpython-35.pyc
project/allocation/__pycache__/urls.cpython-35.pyc
+0
-0
project/allocation/__pycache__/views.cpython-35.pyc
project/allocation/__pycache__/views.cpython-35.pyc
+0
-0
project/allocation/static/allocation/home_page.css
project/allocation/static/allocation/home_page.css
+5
-5
project/allocation/templates/allocation/admin1.html
project/allocation/templates/allocation/admin1.html
+15
-5
project/allocation/templates/allocation/applicant_list.html
project/allocation/templates/allocation/applicant_list.html
+48
-3
project/allocation/templates/allocation/choice_list.html
project/allocation/templates/allocation/choice_list.html
+1
-1
project/allocation/urls.py
project/allocation/urls.py
+1
-0
project/allocation/views.py
project/allocation/views.py
+78
-4
project/db.sqlite3
project/db.sqlite3
+0
-0
project/templates/core/home_page.css
project/templates/core/home_page.css
+1
-1
project/templates/core/home_page.html
project/templates/core/home_page.html
+1
-1
No files found.
project/allocation/__pycache__/urls.cpython-35.pyc
View file @
a8ce99f2
No preview for this file type
project/allocation/__pycache__/views.cpython-35.pyc
View file @
a8ce99f2
No preview for this file type
project/allocation/static/allocation/home_page.css
View file @
a8ce99f2
...
@@ -18,31 +18,31 @@
...
@@ -18,31 +18,31 @@
.content
{
.content
{
position
:
relative
;
position
:
relative
;
margin-top
:
300px
;
margin-top
:
16%
;
font-size
:
60px
;
font-size
:
60px
;
opacity
:
20
;
opacity
:
20
;
}
}
.tool1
{
.tool1
{
margin-top
:
680px
;
/*margin-top: 680px;*/
background-color
:
green
;
background-color
:
green
;
z-index
:
1
;
z-index
:
1
;
}
}
.tool2
{
.tool2
{
margin-top
:
700px
;
/*margin-top: 700px;*/
background-color
:
#5DBCD2
;
background-color
:
#5DBCD2
;
z-index
:
1
;
z-index
:
1
;
}
}
.tool3
{
.tool3
{
margin-top
:
720px
;
/*margin-top: 720px;*/
background-color
:
#5DBCD2
;
background-color
:
#5DBCD2
;
z-index
:
1
;
z-index
:
1
;
}
}
.tool4
{
.tool4
{
margin-top
:
720px
;
/*margin-top: 720px;*/
background-color
:
#5DBCD2
;
background-color
:
#5DBCD2
;
z-index
:
1
;
z-index
:
1
;
}
}
\ No newline at end of file
project/allocation/templates/allocation/admin1.html
View file @
a8ce99f2
...
@@ -30,20 +30,30 @@
...
@@ -30,20 +30,30 @@
{% endblock %}
{% endblock %}
{% block content %}
{% block content %}
<p
style=
"font-size: 30px;"
><a
href=
"{% url 'allocation:applicant_list' %}"
>
Applicants
</a></p>
{% if request.get_full_path == "/allocation/admin" %}
<p
style=
"font-size: 30px;"
><a
href=
"{% url 'allocation:choice_list' %}"
>
Choices
</a></p>
<div
style=
"float:right;"
>
<form
method=
"POST"
action=
"/allocation/button_action"
enctype=
"multipart/form-data"
>
{% csrf_token %}
<!-- <input type="hidden" name="prikey" value="{{ request.get_full_path }}"> -->
<button
type=
"submit"
style=
"width: 180px; height: 40px; font-size: 25px"
>
Allocate
</button>
</form>
</div>
{% endif %}
<p
style=
"font-size: 25px; text-align: left;"
><a
href=
"{% url 'allocation:applicant_list' %}"
>
Applicants
</a></p>
<p
style=
"font-size: 25px; text-align: left"
><a
href=
"{% url 'allocation:choice_list' %}"
>
Choices
</a></p>
{% if request.get_full_path == "/allocation/admin" %}
<!-- {% if request.get_full_path == "/allocation/admin" %}
<div style="float:right; vertical-align: top; margin-top: -140px">
<div style="float:right; vertical-align: top; margin-top: -140px">
<form method="POST" action="/allocation/button_action" enctype="multipart/form-data">
<form method="POST" action="/allocation/button_action" enctype="multipart/form-data">
{% csrf_token %}
{% csrf_token %}
<input type="hidden" name="prikey" value="{{ request.get_full_path }}">
<input type="hidden" name="prikey" value="{{ request.get_full_path }}">
<button type="submit" style="width: 180px; height: 40px; font-size: 25px"> Allocate</button>
<button type="submit" style="width: 180px; height: 40px; font-size: 25px"> Allocate</button>
</form>
</form>
<div>
<div>
-->
{% endif %}
<!-- {% endif %} -->
{% endblock %}
{% endblock %}
project/allocation/templates/allocation/applicant_list.html
View file @
a8ce99f2
...
@@ -9,14 +9,57 @@
...
@@ -9,14 +9,57 @@
{% block content %}
{% block content %}
<h1>
Applicants
</h1>
<h1>
Applicants
</h1>
<!-- <script>
function validate_fileupload(fileName){
var allowed_extensions = "csv";
var file_extension = fileName.split('.').pop();
// document.getElementById('errfn').innerHTML = file_extension;
if(allowed_extensions==file_extension){
return true; // valid file extension
}
// document.getElementById('errfn').innerHTML = "This is not a valid file format";
alert("Sorry, only .txt files are allowed");
return false;
}
</script> -->
<!--
{% if success %}
<ul>
<li style="float:right; vertical-align: top;">
<h3 style="margin-top: -50px"> For uploading Applicant</h3>
<form name="myform" method="POST" action="/allocation/applicant_make" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="myfile" accept=".csv" id="upload_file" title='Please upload file in .csv format only'>
<button type="submit">Upload</button>
<div id="errfn">
<p style="color:red">Invalid input</p>
</div>
</form>
</li>
{% for applicant in applicant_list %}
<li>
<a href="{% url 'allocation:applicant-detail' applicant.pk %}">{{ applicant.name }}</a>
</li>
{% endfor %}
</ul>
{% else %} -->
{% if applicant_list %}
{% if applicant_list %}
<ul>
<ul>
<li
style=
"float:right; vertical-align: top;"
>
<li
style=
"float:right; vertical-align: top;"
>
<h3
style=
"margin-top: -50px"
>
For uploading Applicant
</h3>
<h3
style=
"margin-top: -50px"
>
For uploading Applicant
</h3>
<form
method=
"POST"
action=
"/allocation/applicant_make"
enctype=
"multipart/form-data"
>
<form
name=
"myform"
method=
"POST"
action=
"/allocation/applicant_make"
enctype=
"multipart/form-data"
>
{% csrf_token %}
{% csrf_token %}
<input
type=
"file"
name=
"myfile"
title=
'Please upload file in .csv format only'
>
<input
type=
"file"
name=
"myfile"
accept=
".csv"
id=
"upload_file"
title=
'Please upload file in .csv format only'
>
<button
type=
"submit"
>
Upload
</button>
<button
type=
"submit"
>
Upload
</button>
<div
id=
"errfn"
>
{% if success %}
<p
style=
"color:red"
>
Invalid input
</p>
{% endif %}
</div>
</form>
</form>
</li>
</li>
{% for applicant in applicant_list %}
{% for applicant in applicant_list %}
...
@@ -31,10 +74,12 @@
...
@@ -31,10 +74,12 @@
<h3
style=
"margin-top: -50px"
>
For uploading Applicant
</h3>
<h3
style=
"margin-top: -50px"
>
For uploading Applicant
</h3>
<form
method=
"POST"
action=
"/allocation/applicant_make"
enctype=
"multipart/form-data"
>
<form
method=
"POST"
action=
"/allocation/applicant_make"
enctype=
"multipart/form-data"
>
{% csrf_token %}
{% csrf_token %}
<input
type=
"file"
name=
"myfile"
title=
'Please upload file in .csv format only'
>
<input
type=
"file"
name=
"myfile"
accept=
".csv"
title=
'Please upload file in .csv format only'
>
<button
type=
"submit"
>
Upload
</button>
<button
type=
"submit"
>
Upload
</button>
</form>
</form>
</li>
</li>
<p>
There are no applicants.
</p>
<p>
There are no applicants.
</p>
{% endif %}
{% endif %}
<!-- {% endif %} -->
{% endblock %}
{% endblock %}
project/allocation/templates/allocation/choice_list.html
View file @
a8ce99f2
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
<h3
style=
"margin-top: -50px"
>
For uploading choices
</h3>
<h3
style=
"margin-top: -50px"
>
For uploading choices
</h3>
<form
method=
"POST"
action=
"/allocation/choice_make"
enctype=
"multipart/form-data"
>
<form
method=
"POST"
action=
"/allocation/choice_make"
enctype=
"multipart/form-data"
>
{% csrf_token %}
{% csrf_token %}
<input
type=
"file"
name=
"myfile"
title=
'Please upload file in .csv format only'
>
<input
type=
"file"
accept=
".csv"
name=
"myfile"
title=
'Please upload file in .csv format only'
>
<button
type=
"submit"
>
Upload
</button>
<button
type=
"submit"
>
Upload
</button>
</form>
</form>
</li>
</li>
...
...
project/allocation/urls.py
View file @
a8ce99f2
...
@@ -18,6 +18,7 @@ urlpatterns = [
...
@@ -18,6 +18,7 @@ urlpatterns = [
url
(
r'^choice_make$'
,
views
.
choice_make
,
name
=
'choice_make'
),
url
(
r'^choice_make$'
,
views
.
choice_make
,
name
=
'choice_make'
),
url
(
r'^applicant_make$'
,
views
.
applicant_make
,
name
=
'applicant_make'
),
url
(
r'^applicant_make$'
,
views
.
applicant_make
,
name
=
'applicant_make'
),
url
(
r'^button_action$'
,
views
.
button_action
,
name
=
'button_action'
),
url
(
r'^button_action$'
,
views
.
button_action
,
name
=
'button_action'
),
# url(r'^send_mail$', views.send_mail, name='mail_send'),
#url(r'^admin/choices$', views.ChoiceListView.as_view(), name='choice_list'),
#url(r'^admin/choices$', views.ChoiceListView.as_view(), name='choice_list'),
#url(r'^admin/applicants$', views.ApplicantListView.as_view(), name='applicant_list'),
#url(r'^admin/applicants$', views.ApplicantListView.as_view(), name='applicant_list'),
...
...
project/allocation/views.py
View file @
a8ce99f2
...
@@ -19,7 +19,25 @@ from django import forms
...
@@ -19,7 +19,25 @@ from django import forms
import
csv
import
csv
from
django.urls
import
reverse_lazy
from
django.urls
import
reverse_lazy
from
django.utils
import
lru_cache
from
django.utils._os
import
upath
from
django.utils.encoding
import
force_text
from
django.utils.functional
import
lazy
from
django.utils.html
import
format_html
from
django.utils.module_loading
import
import_string
from
django.utils.six
import
string_types
,
text_type
from
django.utils.translation
import
ugettext
as
_
,
ungettext
from
django.contrib.auth
import
*
from
alloc
import
*
from
alloc
import
*
from
difflib
import
SequenceMatcher
from
django.core.mail
import
send_mail
from
django.core.mail
import
EmailMessage
from
django.core.exceptions
import
(
FieldDoesNotExist
,
ImproperlyConfigured
,
ValidationError
,
)
# @login_required(login_url='/admin/login')
# @login_required(login_url='/admin/login')
# def index(request): #for /allocation
# def index(request): #for /allocation
...
@@ -30,6 +48,16 @@ from alloc import *
...
@@ -30,6 +48,16 @@ from alloc import *
# form = ArticleForm(instance=applicant)
# form = ArticleForm(instance=applicant)
# return render(request, 'allocation/index.html', {'applicant': applicant, 'form': form})
# return render(request, 'allocation/index.html', {'applicant': applicant, 'form': form})
# def send_mail(request):
# # send_mail('Subject here', 'Here is the message.', settings.EMAIL_HOST_USER,['to@example.com'], fail_silently=False)
# email = EmailMessage(
# 'subject_message',
# 'content_message',
# 'sender smtp gmail' +'<codemafia123@gmail.com>',
# ['codemafia123@gmail.com'],)
# email.send()
# return HttpResponse("success")
def
button_action
(
request
):
def
button_action
(
request
):
# value = request.POST["prikey"]
# value = request.POST["prikey"]
# value = int(value.split('/')[-3])
# value = int(value.split('/')[-3])
...
@@ -54,13 +82,38 @@ def choice_make(request):
...
@@ -54,13 +82,38 @@ def choice_make(request):
institute
=
Institute
.
objects
.
filter
(
name
=
user_name
)[
0
]
institute
=
Institute
.
objects
.
filter
(
name
=
user_name
)[
0
]
for
line
in
lines
:
for
line
in
lines
:
line
=
line
.
split
(
','
)
line
=
line
.
split
(
','
)
# tmp = Choice.objects.create(choice_name=line[0],capacity=line[1])
number
=
len
(
line
)
if
number
!=
2
:
return
HttpResponse
(
"Incorrect data format in uploaded .csv file."
)
existing_no
=
institute
.
choices
.
filter
(
choice_name
=
line
[
0
])
if
existing_no
.
count
()
!=
0
:
return
HttpResponse
(
".csv file has choices that already exists"
)
for
line
in
lines
:
line
=
line
.
split
(
','
)
tmp
=
institute
.
choices
.
create
(
choice_name
=
line
[
0
],
capacity
=
line
[
1
])
tmp
=
institute
.
choices
.
create
(
choice_name
=
line
[
0
],
capacity
=
line
[
1
])
tmp
.
save
()
tmp
.
save
()
# tmp = Choice.objects.create(choice_name=line[0],capacity=line[1])
return
HttpResponse
(
"successful"
)
return
HttpResponse
(
"successful"
)
return
HttpResponse
(
"Error"
)
return
HttpResponse
(
"Error"
)
@
lru_cache
.
lru_cache
(
maxsize
=
None
)
def
get_default_password_validators
():
return
get_password_validators
(
settings
.
AUTH_PASSWORD_VALIDATORS
)
def
get_password_validators
(
validator_config
):
validators
=
[]
for
validator
in
validator_config
:
try
:
klass
=
import_string
(
validator
[
'NAME'
])
except
ImportError
:
msg
=
"The module in NAME could not be imported:
%
s. Check your AUTH_PASSWORD_VALIDATORS setting."
raise
ImproperlyConfigured
(
msg
%
validator
[
'NAME'
])
validators
.
append
(
klass
(
**
validator
.
get
(
'OPTIONS'
,
{})))
return
validators
def
applicant_make
(
request
):
def
applicant_make
(
request
):
if
request
.
method
==
"POST"
:
if
request
.
method
==
"POST"
:
csvfile
=
request
.
FILES
[
'myfile'
]
csvfile
=
request
.
FILES
[
'myfile'
]
...
@@ -70,10 +123,31 @@ def applicant_make(request):
...
@@ -70,10 +123,31 @@ def applicant_make(request):
lines
=
file_data
.
split
(
"
\n
"
)
lines
=
file_data
.
split
(
"
\n
"
)
for
line
in
lines
:
for
line
in
lines
:
line
=
line
.
split
(
','
)
line
=
line
.
split
(
','
)
# tmp = Applicant.objects.create(name = line[0],rank=line[1])
number
=
len
(
line
)
if
number
!=
4
:
return
HttpResponse
(
"Incorrect data format in uploaded .csv file"
)
existing_no_app
=
institute
.
applicants
.
filter
(
name
=
line
[
0
],
rank
=
line
[
1
])
existing_no_user
=
User
.
objects
.
filter
(
username
=
line
[
0
],
email
=
line
[
2
],
password
=
line
[
3
])
if
existing_no_app
.
count
()
!=
0
:
return
HttpResponse
(
".csv files has applicants that already exists"
)
if
existing_no_user
.
count
()
!=
0
:
return
HttpResponse
(
"user with same username,password and email-id already exists"
)
errors
=
[]
password_validators
=
get_default_password_validators
()
for
validator
in
password_validators
:
try
:
validator
.
validate
(
line
[
3
])
except
ValidationError
as
error
:
errors
.
append
(
error
)
if
errors
:
return
HttpResponse
(
"Invalid password given in .csv file"
)
# if validate_password(line[4]) != None:
# return HttpResponse("Invalid password given in .csv file")
for
line
in
lines
:
line
=
line
.
split
(
','
)
tmp
=
institute
.
applicants
.
create
(
name
=
line
[
0
],
rank
=
line
[
1
])
tmp
=
institute
.
applicants
.
create
(
name
=
line
[
0
],
rank
=
line
[
1
])
tmp
.
save
()
tmp
.
save
()
user
=
User
.
objects
.
create_user
(
username
=
line
[
2
],
email
=
line
[
3
],
password
=
line
[
4
])
user
=
User
.
objects
.
create_user
(
username
=
line
[
0
],
email
=
line
[
2
],
password
=
line
[
3
])
user
.
is_staff
=
True
user
.
is_staff
=
True
user
.
save
()
user
.
save
()
return
HttpResponse
(
"successful"
)
return
HttpResponse
(
"successful"
)
...
...
project/db.sqlite3
View file @
a8ce99f2
No preview for this file type
project/templates/core/home_page.css
View file @
a8ce99f2
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
right
:
0
;
right
:
0
;
z-index
:
-1
;
z-index
:
-1
;
/*background-image: url('BG.png');*/
/*background-image: url('BG.png');*/
background-size
:
2000px
700px
;
background-size
:
100%
25%
;
background-repeat
:
no-repeat
;
background-repeat
:
no-repeat
;
background-attachment
:
fixed
;
background-attachment
:
fixed
;
opacity
:
0.60
;
opacity
:
0.60
;
...
...
project/templates/core/home_page.html
View file @
a8ce99f2
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
<div
class=
"content"
><h1
align=
"center"
style=
"color:black"
>
General Allocation Portal
</h1></div>
<div
class=
"content"
><h1
align=
"center"
style=
"color:black"
>
General Allocation Portal
</h1></div>
</div>
</div>
<div
class=
"tool1"
style=
"margin-top:
460px
; text-align: center; font-size: 30px;"
>
<div
class=
"tool1"
style=
"margin-top:
29%
; text-align: center; font-size: 30px;"
>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment