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
b7d5c58d
Commit
b7d5c58d
authored
Oct 17, 2017
by
EASHAN GUPTA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added univs
parent
0cec1ba9
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
172 additions
and
10 deletions
+172
-10
project/alloc.py
project/alloc.py
+3
-3
project/allocation/__pycache__/admin.cpython-35.pyc
project/allocation/__pycache__/admin.cpython-35.pyc
+0
-0
project/allocation/__pycache__/models.cpython-35.pyc
project/allocation/__pycache__/models.cpython-35.pyc
+0
-0
project/allocation/admin.py
project/allocation/admin.py
+13
-3
project/allocation/migrations/0001_initial.py
project/allocation/migrations/0001_initial.py
+95
-0
project/allocation/migrations/0002_auto_20171017_0132.py
project/allocation/migrations/0002_auto_20171017_0132.py
+37
-0
project/allocation/migrations/__init__.py
project/allocation/migrations/__init__.py
+0
-0
project/allocation/migrations/__pycache__/0001_initial.cpython-35.pyc
...cation/migrations/__pycache__/0001_initial.cpython-35.pyc
+0
-0
project/allocation/migrations/__pycache__/0002_auto_20171017_0132.cpython-35.pyc
...ations/__pycache__/0002_auto_20171017_0132.cpython-35.pyc
+0
-0
project/allocation/migrations/__pycache__/__init__.cpython-35.pyc
...allocation/migrations/__pycache__/__init__.cpython-35.pyc
+0
-0
project/allocation/models.py
project/allocation/models.py
+24
-4
project/db.sqlite3
project/db.sqlite3
+0
-0
No files found.
project/alloc.py
View file @
b7d5c58d
from
allocation.models
import
*
def
f
(
univ
):
a
=
Applicant
.
objects
.
filter
(
university
.
objects
.
all
()[
0
]
.
name
=
univ
)
.
order_by
(
'rank'
)
c
=
Choice
.
objects
.
all
(
)
def
allocator
(
univ
):
a
=
Applicant
.
objects
.
filter
(
institute__
name
=
univ
)
.
order_by
(
'rank'
)
c
=
Choice
.
objects
.
filter
(
institute__name
=
univ
)
my_dict
=
dict
([(
x
,
0
)
for
x
in
c
])
for
x
in
a
:
choices
=
x
.
ordered_choices
()
...
...
project/allocation/__pycache__/admin.cpython-35.pyc
View file @
b7d5c58d
No preview for this file type
project/allocation/__pycache__/models.cpython-35.pyc
View file @
b7d5c58d
No preview for this file type
project/allocation/admin.py
View file @
b7d5c58d
...
...
@@ -2,6 +2,13 @@ from django.contrib import admin
from
.models
import
*
# class UnivAppInLine(admin.TabularInline):
# model=UnivApp
# extra=0
# class UnivChoiceInLine(admin.TabularInline):
# model=UnivChoice
# extra=0
class
ChoiceInline
(
admin
.
TabularInline
):
model
=
Application
#https://stackoverflow.com/questions/5947843/django-how-does-manytomanyfield-with-through-appear-in-admin
...
...
@@ -12,10 +19,13 @@ class AllotedChoiceToAppInLine(admin.TabularInline):
extra
=
0
class
ApplicantAdmin
(
admin
.
ModelAdmin
):
fields
=
[
'name'
,
'rank'
]
fields
=
[
'name'
,
'rank'
,
'institute'
]
inlines
=
[
ChoiceInline
,
AllotedChoiceToAppInLine
]
# class
admin
.
site
.
register
(
University
)
# class ChoiceAdmin(admin.ModelAdmin):
# fields=['choice_name', 'capacity']
# inlines=[UnivChoiceInLine]
admin
.
site
.
register
(
Institute
)
admin
.
site
.
register
(
Choice
)
admin
.
site
.
register
(
Applicant
,
ApplicantAdmin
)
project/allocation/migrations/0001_initial.py
0 → 100644
View file @
b7d5c58d
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-16 19:42
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Allocationcl'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
],
options
=
{
'ordering'
:
[
'applicant__rank'
],
},
),
migrations
.
CreateModel
(
name
=
'Applicant'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'name'
,
models
.
CharField
(
max_length
=
200
)),
(
'rank'
,
models
.
IntegerField
()),
],
),
migrations
.
CreateModel
(
name
=
'Application'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'priority'
,
models
.
IntegerField
()),
(
'applicant'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'allocation.Applicant'
)),
],
options
=
{
'ordering'
:
[
'priority'
],
},
),
migrations
.
CreateModel
(
name
=
'Choice'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'choice_name'
,
models
.
CharField
(
max_length
=
200
)),
(
'capacity'
,
models
.
IntegerField
()),
],
),
migrations
.
CreateModel
(
name
=
'University'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'name'
,
models
.
CharField
(
max_length
=
200
)),
],
),
migrations
.
AddField
(
model_name
=
'choice'
,
name
=
'university'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'choices'
,
to
=
'allocation.University'
),
),
migrations
.
AddField
(
model_name
=
'application'
,
name
=
'choice'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'allocation.Choice'
),
),
migrations
.
AddField
(
model_name
=
'applicant'
,
name
=
'alloted_choice'
,
field
=
models
.
ManyToManyField
(
related_name
=
'alloted_applicant'
,
through
=
'allocation.Allocationcl'
,
to
=
'allocation.Choice'
),
),
migrations
.
AddField
(
model_name
=
'applicant'
,
name
=
'choices'
,
field
=
models
.
ManyToManyField
(
related_name
=
'applicants'
,
through
=
'allocation.Application'
,
to
=
'allocation.Choice'
),
),
migrations
.
AddField
(
model_name
=
'applicant'
,
name
=
'university'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'applicants'
,
to
=
'allocation.University'
),
),
migrations
.
AddField
(
model_name
=
'allocationcl'
,
name
=
'applicant'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'allocation.Applicant'
),
),
migrations
.
AddField
(
model_name
=
'allocationcl'
,
name
=
'choice'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'allocation.Choice'
),
),
]
project/allocation/migrations/0002_auto_20171017_0132.py
0 → 100644
View file @
b7d5c58d
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-16 20:02
from
__future__
import
unicode_literals
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'allocation'
,
'0001_initial'
),
]
operations
=
[
migrations
.
RenameModel
(
old_name
=
'University'
,
new_name
=
'Institute'
,
),
migrations
.
AlterModelOptions
(
name
=
'allocationcl'
,
options
=
{
'ordering'
:
[
'applicant__rank'
],
'verbose_name'
:
'Allocated Choice'
,
'verbose_name_plural'
:
'Allocated Choice'
},
),
migrations
.
AlterModelOptions
(
name
=
'institute'
,
options
=
{
'verbose_name'
:
'Institute'
,
'verbose_name_plural'
:
'Institutes'
},
),
migrations
.
RenameField
(
model_name
=
'applicant'
,
old_name
=
'university'
,
new_name
=
'institute'
,
),
migrations
.
RenameField
(
model_name
=
'choice'
,
old_name
=
'university'
,
new_name
=
'institute'
,
),
]
project/allocation/migrations/__init__.py
0 → 100644
View file @
b7d5c58d
project/allocation/migrations/__pycache__/0001_initial.cpython-35.pyc
0 → 100644
View file @
b7d5c58d
File added
project/allocation/migrations/__pycache__/0002_auto_20171017_0132.cpython-35.pyc
0 → 100644
View file @
b7d5c58d
File added
project/allocation/migrations/__pycache__/__init__.cpython-35.pyc
0 → 100644
View file @
b7d5c58d
File added
project/allocation/models.py
View file @
b7d5c58d
from
django.db
import
models
# import math
class
University
(
models
.
Model
):
class
Institute
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
200
)
def
__str__
(
self
):
return
self
.
name
class
Meta
:
verbose_name
=
'Institute'
verbose_name_plural
=
'Institutes'
class
Choice
(
models
.
Model
):
choice_name
=
models
.
CharField
(
max_length
=
200
)
university
=
models
.
ForeignKey
(
University
,
on_delete
=
models
.
CASCADE
,
related_name
=
'choices'
)
institute
=
models
.
ForeignKey
(
Institute
,
on_delete
=
models
.
CASCADE
,
related_name
=
'choices'
)
capacity
=
models
.
IntegerField
()
def
__str__
(
self
):
return
self
.
choice_name
...
...
@@ -14,11 +20,11 @@ class Choice(models.Model):
# Null_Choice.save()
class
Applicant
(
models
.
Model
):
institute
=
models
.
ForeignKey
(
Institute
,
on_delete
=
models
.
CASCADE
,
related_name
=
'applicants'
)
choices
=
models
.
ManyToManyField
(
Choice
,
through
=
'Application'
,
related_name
=
'applicants'
)
name
=
models
.
CharField
(
max_length
=
200
)
alloted_choice
=
models
.
ManyToManyField
(
Choice
,
through
=
'Allocationcl'
,
related_name
=
'alloted_applicant'
)
rank
=
models
.
IntegerField
()
university
=
models
.
ForeignKey
(
University
,
on_delete
=
models
.
CASCADE
,
related_name
=
'applicants'
)
def
__str__
(
self
):
return
self
.
name
def
ordered_choices
(
self
):
...
...
@@ -27,12 +33,13 @@ class Applicant(models.Model):
return
self
.
choices
.
all
()
.
order_by
(
'application__priority'
)
class
Application
(
models
.
Model
):
choice
=
models
.
ForeignKey
(
Choice
,
on_delete
=
models
.
CASCADE
)
applicant
=
models
.
ForeignKey
(
Applicant
,
on_delete
=
models
.
CASCADE
)
choice
=
models
.
ForeignKey
(
Choice
,
on_delete
=
models
.
CASCADE
)
priority
=
models
.
IntegerField
()
class
Meta
:
# if you have an inline configured in the admin, this will
# make the roles order properly
ordering
=
[
'priority'
]
...
...
@@ -43,4 +50,17 @@ class Allocationcl(models.Model):
class
Meta
:
# if you have an inline configured in the admin, this will
# make the roles order properly
verbose_name
=
'Allocated Choice'
verbose_name_plural
=
'Allocated Choice'
ordering
=
[
'applicant__rank'
]
# class UnivChoice(models.Model):
# ,limit_choices_to={'institute':applicant.institute}
# choice=models.ForeignKey(Choice,on_delete=models.CASCADE)
# university=models.ForeignKey(University,on_delete=models.CASCADE)
# , limit_choices_to={'university__name':'applicant_university__name'}
# class UnivApp(models.Model):
# applicant=models.ForeignKey(Applicant,on_delete=models.CASCADE)
# university=models.ForeignKey(University,on_delete=models.CASCADE)
# class Meta:
# ordering=['applicant__rank']
\ No newline at end of file
project/db.sqlite3
View file @
b7d5c58d
No preview for this file type
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