Commit 244c4535 authored by KUNAL GOYAL's avatar KUNAL GOYAL

bug fixes and interface change

parent 2d35b209
......@@ -6,7 +6,8 @@ from allocation.models import *
# @param univ Name of the institute
# @return list of applicants which also store their newly allocated choices
def allocator(univ):
insti=Institute.objects.filter(name=univ)[0]
insti=get_object_or_404(Institute, name=univ)
insti.round_num = insti.round_num + 1
insti.is_allocated=True #< Sets that the institute has allocated atleast once
insti.save() #< save changes to institute model instance
a=Applicant.objects.filter(institute__name=univ).order_by('rank') #< variable \c a \ stores the list of applicants in order of their ranks
......
......@@ -17,8 +17,8 @@ class ApplicantAdmin(admin.ModelAdmin):
inlines = [ChoiceInline, AllotedChoiceToAppInLine]
class InstituteAdmin(admin.ModelAdmin):
fields=['name', 'is_allocated']
list_display=['name','is_allocated']
fields=['name', 'is_allocated', 'round_num']
list_display=['name','is_allocated', 'round_num']
class ChoiceAdmin(admin.ModelAdmin):
fields=['choice_name', 'capacity','institute']
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-28 19:07
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('allocation', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='applicant',
options={'ordering': ['institute__name', 'rank']},
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-28 19:53
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('allocation', '0002_auto_20171029_0037'),
]
operations = [
migrations.AlterModelOptions(
name='choice',
options={'ordering': ['institute__name', 'choice_name']},
),
migrations.AddField(
model_name='institute',
name='round_num',
field=models.IntegerField(default=1),
),
]
......@@ -10,6 +10,7 @@ import os
# @brief Stores information about all institutes in a table
class Institute(models.Model):
name=models.CharField(max_length=200) #< name of the Institute
round_num = models.IntegerField(default=1) #<Stores the number of rounds completed
is_allocated=models.BooleanField(default=False) #< Stores if atleast \f$1^{st}\f$ round is over or not
## String Conversion
# @param self Pointer to itself
......@@ -32,6 +33,9 @@ class Choice(models.Model):
# @return name Name of Choice
def __str__(self):
return self.choice_name
## Metadata
class Meta:
ordering = ['institute__name', 'choice_name']
## Applicant Model
# @brief Stores various applicants in a table
......@@ -53,6 +57,10 @@ class Applicant(models.Model):
# @return list of choices in order of preference
def ordered_choices(self):
return self.choices.all().order_by('application__priority')
## Metadata
class Meta:
ordering = ['institute__name', 'rank']
## Application Model
# @brief Links an Applicant to a Choice through a model
......
{% extends "admin/base.html" %}
{% load i18n admin_urls static admin_list %}
<!-- added by aman -->
{% load tag %}
<!-- -->
{% block branding %}
<h1 id="site-name">Institute Homepage</h1>
{% endblock %}
......@@ -39,20 +37,9 @@
</div>
{% endif %}
<p style="font-size: 20px; text-align: left;">Ongoing Round: {{institute.round_num}}</p>
<p style="font-size: 20px; text-align: left;"><a href="{% url 'allocation:applicant_list' %}">Applicants</a></p>
<p style="font-size: 20px; text-align: left"><a href="{% url 'allocation:choice_list' %}">Choices</a></p>
<!-- {% if request.get_full_path == "/allocation/admin" %}
<div style="float:right; vertical-align: top; margin-top: -140px">
<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 %} -->
{% endblock %}
......@@ -24,11 +24,22 @@
</div>
</form>
</li>
<table style="width:100%">
<tr>
<th>Name</th>
<th>Rank</th>
<th>Allocated choice</th>
</tr>
{% for applicant in applicant_list %}
<li>
<a href="{% url 'allocation:applicant-detail' applicant.pk %}">{{ applicant.name }}</a>
</li>
<tr>
<td> <a href="{% url 'allocation:applicant-detail' applicant.pk %}">{{ applicant.name }}</a></td>
<td> {{ applicant.rank }}</td>
<td> {% for choice in applicant.alloted_choice.all %}
{{choice}}
{% endfor %}</td>
</tr>
{% endfor %}
</table>
</ul>
{% else %}
......@@ -43,5 +54,4 @@
<p>There are no applicants.</p>
{% endif %}
<!-- {% endif %} -->
{% endblock %}
......@@ -21,8 +21,7 @@
<br>
<p>List of Applicants who have been allocated {{ choice.choice_name }} choice: </p>
<ul>
{% for applicant in choice.alloted_applicant.all %}
<table style="width:100%">
<table style="width:100%">
<tr>
<th>Name</th>
<th>Rank</th>
......@@ -33,8 +32,7 @@
<td> {{ applicant.rank }}</td>
</tr>
{% endfor %}
</table>
{% endfor %}
</table>
</ul>
{% else %}
Unauthorised access
......
......@@ -60,6 +60,7 @@
<p> <b>Name:</b> {{applicant.name}}<br>
<b>Institute:</b> {{applicant.institute}}<br>
<b>Rank:</b> {{applicant.rank}}<br>
<b>Ongoing Round:</b> {{applicant.institute.round_num}}<br>
<b>Allocated choice:</b>
{% for choice in applicant.alloted_choice.all %}
{{choice}}
......
No preview for this file type
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