Commit 9414fe04 authored by KUNAL GOYAL's avatar KUNAL GOYAL

some changes

parents a14355dd 33dc204e
No preview for this file type
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-21 10:18 # Generated by Django 1.11.5 on 2017-10-22 19:07
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models
......
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
bottom: 0; bottom: 0;
left: 0; left: 0;
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: 2000px 700px;*/
background-size: 100% 75%;
background-repeat: no-repeat; background-repeat: no-repeat;
background-attachment: fixed; background-attachment: fixed;
opacity: 0.60; opacity: 0.60;
...@@ -17,27 +18,31 @@ ...@@ -17,27 +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;
} }
.tool2 { .tool2 {
margin-top: 700px; /*margin-top: 700px;*/
background-color: #5DBCD2; background-color: #5DBCD2;
z-index: 1;
} }
.tool3 { .tool3 {
margin-top: 720px; /*margin-top: 720px;*/
background-color: #5DBCD2; background-color: #5DBCD2;
z-index: 1;
} }
.tool4 { .tool4 {
margin-top: 720px; /*margin-top: 720px;*/
background-color: #5DBCD2; background-color: #5DBCD2;
z-index: 1;
} }
\ No newline at end of file
{% extends "admin/base.html" %} {% extends "admin/base.html" %}
{% load i18n admin_urls static admin_list %} {% load i18n admin_urls static admin_list %}
<!-- added by aman -->
{% load tag %}
<!-- -->
{% block branding %} {% block branding %}
<h1 id="site-name">Institute Homepage</h1> <h1 id="site-name">Institute Homepage</h1>
{% endblock %} {% endblock %}
...@@ -26,6 +30,20 @@ ...@@ -26,6 +30,20 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<p><a href="{% url 'allocation:applicant_list' %}">Applicants</a></p> <p style="font-size: 30px;"><a href="{% url 'allocation:applicant_list' %}">Applicants</a></p>
<p><a href="{% url 'allocation:choice_list' %}">Choices</a></p> <p style="font-size: 30px;"><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 %} {% endblock %}
...@@ -11,7 +11,14 @@ ...@@ -11,7 +11,14 @@
{% if applicant_list %} {% if applicant_list %}
<ul> <ul>
<li style="float:right; vertical-align: top;">
<h3 style="margin-top: -50px"> For uploading Applicant</h3>
<form method="POST" action="/allocation/applicant_make" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="myfile" title='Please upload file in .csv format only'>
<button type="submit">Upload</button>
</form>
</li>
{% for applicant in applicant_list %} {% for applicant in applicant_list %}
<li> <li>
<a href="{% url 'allocation:applicant-detail' applicant.pk %}">{{ applicant.name }}</a> <a href="{% url 'allocation:applicant-detail' applicant.pk %}">{{ applicant.name }}</a>
...@@ -20,6 +27,14 @@ ...@@ -20,6 +27,14 @@
</ul> </ul>
{% else %} {% else %}
<li style="float:right; vertical-align: top;">
<h3 style="margin-top: -50px"> For uploading Applicant</h3>
<form method="POST" action="/allocation/applicant_make" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="myfile" title='Please upload file in .csv format only'>
<button type="submit">Upload</button>
</form>
</li>
<p>There are no applicants.</p> <p>There are no applicants.</p>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
...@@ -12,14 +12,37 @@ ...@@ -12,14 +12,37 @@
{% if choice_list %} {% if choice_list %}
<ul> <ul>
<li style="float:right; vertical-align: top;">
<h3 style="margin-top: -50px"> For uploading choices</h3>
<form method="POST" action="/allocation/choice_make" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="myfile" title='Please upload file in .csv format only'>
<button type="submit">Upload</button>
</form>
</li>
{% for choice in choice_list %} {% for choice in choice_list %}
<li> <li>
<a href="{% url 'allocation:choice-detail' choice.pk %}">{{ choice.choice_name }}</a> <a href="{% url 'allocation:choice-detail' choice.pk %}">{{ choice.choice_name }}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
{% else %} {% else %}
<li style="float:right; vertical-align: top;"">
<h3 style="margin-top: -50px"> For uploading choices</h3>
<form method="POST" action="/allocation/choice_make" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="myfile" title='Please upload file in .csv format only'>
<button type="submit">Upload</button>
</form>
</li>
<p>There are no choices available.</p> <p>There are no choices available.</p>
{% endif %} {% endif %}
</div>
{% endblock %} {% endblock %}
from django import template
register = template.Library()
@register.assignment_tag
def hello_world(name):
value = name.split('/')[-4]
if value == "institute": return True; return False
\ No newline at end of file
...@@ -15,9 +15,9 @@ urlpatterns = [ ...@@ -15,9 +15,9 @@ urlpatterns = [
url(r'^choice/create$', views.ChoiceCreateView.as_view(), name='choice-create'), url(r'^choice/create$', views.ChoiceCreateView.as_view(), name='choice-create'),
url(r'^choice/(?P<pk>\d+)/update$', views.ChoiceUpdate.as_view(), name='choice-update'), url(r'^choice/(?P<pk>\d+)/update$', views.ChoiceUpdate.as_view(), name='choice-update'),
url(r'^choice/(?P<pk>\d+)/delete$', views.ChoiceDelete.as_view(), name='choice-delete'), url(r'^choice/(?P<pk>\d+)/delete$', views.ChoiceDelete.as_view(), name='choice-delete'),
url(r'^import_db$', views.import_db, name='import_db1'), 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'^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'),
......
...@@ -19,6 +19,8 @@ from django import forms ...@@ -19,6 +19,8 @@ from django import forms
import csv import csv
from django.urls import reverse_lazy from django.urls import reverse_lazy
from alloc import *
# @login_required(login_url='/admin/login') # @login_required(login_url='/admin/login')
# def index(request): #for /allocation # def index(request): #for /allocation
# applicant=Applicant.objects.filter(name=request.user.username)[0] # applicant=Applicant.objects.filter(name=request.user.username)[0]
...@@ -28,18 +30,22 @@ from django.urls import reverse_lazy ...@@ -28,18 +30,22 @@ from django.urls import reverse_lazy
# 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 index(request): def button_action(request):
return HttpResponse("Hello, world. You're at the allocation index.") # value = request.POST["prikey"]
# value = int(value.split('/')[-3])
def index1(request): # name = Institute.objects.get(pk=value).name
return render(request,'core/home_page.html') # allocator(name)
# return HttpResponse("success")
institute=request.user.username
allocator(institute)
return HttpResponse("success")
def home(request): def home(request):
documents = Document.objects.all() documents = Document.objects.all()
return render(request, 'core/home.html', { 'documents': documents }) return render(request, 'core/home.html', { 'documents': documents })
return HttpResponse("On home") return HttpResponse("On home")
def import_db(request): def choice_make(request):
if request.method == "POST": if request.method == "POST":
csvfile = request.FILES['myfile'] csvfile = request.FILES['myfile']
file_data = csvfile.read().decode("utf-8") file_data = csvfile.read().decode("utf-8")
...@@ -78,12 +84,11 @@ AppFormset = modelformset_factory(Application,fields=("choice", "priority" ), ex ...@@ -78,12 +84,11 @@ AppFormset = modelformset_factory(Application,fields=("choice", "priority" ), ex
@login_required(login_url='/admin/login') @login_required(login_url='/admin/login')
def index(request): #for /allocation def index(request): #for /allocation
applicant=get_object_or_404(Applicant, name=request.user.username)[0] applicant=get_object_or_404(Applicant, name=request.user.username)
# form1 = modelform_factory(Applicant, fields=("name", "rank" )) # form1 = modelform_factory(Applicant, fields=("name", "rank" ))
formset = AppFormset(queryset=Application.objects.filter(applicant=applicant),) formset = AppFormset(queryset=Application.objects.filter(applicant=applicant),)
return render(request, 'allocation/index.html', {'applicant': applicant, 'formset': formset,}) return render(request, 'allocation/index.html', {'applicant': applicant, 'formset': formset,})
# def submit(request): # def submit(request):
# if request.method == 'POST': # if request.method == 'POST':
# formset = AppFormset(request.POST) # formset = AppFormset(request.POST)
...@@ -107,36 +112,36 @@ def submit(request): ...@@ -107,36 +112,36 @@ def submit(request):
@login_required(login_url='/admin/login') @login_required(login_url='/admin/login')
def admin1(request): def admin1(request):
institute=get_object_or_404(Institute,name=request.user.username)[0] institute=get_object_or_404(Institute,name=request.user.username)
return render(request, 'allocation/admin1.html',{'institute': institute}) return render(request, 'allocation/admin1.html',{'institute': institute})
class ChoiceListView(generic.ListView): class ChoiceListView(generic.ListView):
model = Choice model = Choice
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
institute=get_object_or_404(Institute,name=request.user.username)[0] institute=get_object_or_404(Institute,name=self.request.user.username)
context = super(ChoiceListView, self).get_context_data(**kwargs) context = super(ChoiceListView, self).get_context_data(**kwargs)
context['institute'] = institute context['institute'] = institute
return context return context
def get_queryset(self): def get_queryset(self):
institute=get_object_or_404(Institute,name=request.user.username)[0] institute=get_object_or_404(Institute,name=self.request.user.username)
return Choice.objects.filter(institute__name=institute.name) return Choice.objects.filter(institute__name=institute.name)
class ApplicantListView(generic.ListView): class ApplicantListView(generic.ListView):
model = Applicant model = Applicant
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
institute=get_object_or_404(Institute,name=request.user.username)[0] institute=get_object_or_404(Institute,name=self.request.user.username)
context = super(ApplicantListView, self).get_context_data(**kwargs) context = super(ApplicantListView, self).get_context_data(**kwargs)
context['institute'] = institute context['institute'] = institute
return context return context
def get_queryset(self): def get_queryset(self):
institute=get_object_or_404(Institute,name=request.user.username)[0] institute=get_object_or_404(Institute,name=self.request.user.username)
return Applicant.objects.filter(institute__name=institute.name) return Applicant.objects.filter(institute__name=institute.name)
class ChoiceDetailView(generic.DetailView): class ChoiceDetailView(generic.DetailView):
model = Choice model = Choice
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
institute=get_object_or_404(Institute,name=request.user.username)[0] institute=get_object_or_404(Institute,name=self.request.user.username)
context = super(ChoiceDetailView, self).get_context_data(**kwargs) context = super(ChoiceDetailView, self).get_context_data(**kwargs)
context['institute'] = institute context['institute'] = institute
return context return context
...@@ -144,11 +149,12 @@ class ChoiceDetailView(generic.DetailView): ...@@ -144,11 +149,12 @@ class ChoiceDetailView(generic.DetailView):
class ApplicantDetailView(generic.DetailView): class ApplicantDetailView(generic.DetailView):
model = Applicant model = Applicant
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
institute=get_object_or_404(Institute,name=request.user.username)[0] institute=get_object_or_404(Institute,name=self.request.user.username)
context = super(ApplicantDetailView, self).get_context_data(**kwargs) context = super(ApplicantDetailView, self).get_context_data(**kwargs)
context['institute'] = institute context['institute'] = institute
return context return context
class ChoiceCreateView(CreateView): class ChoiceCreateView(CreateView):
model = Choice model = Choice
fields = ['choice_name', 'capacity', 'institute'] fields = ['choice_name', 'capacity', 'institute']
...@@ -157,7 +163,7 @@ class ChoiceUpdate(UpdateView): ...@@ -157,7 +163,7 @@ class ChoiceUpdate(UpdateView):
model = Choice model = Choice
fields = ['choice_name','capacity'] fields = ['choice_name','capacity']
template_name_suffix = '_update' template_name_suffix = '_update'
success_url = 'allocation:choice_list' success_url = reverse_lazy('allocation:choice_list')
class ChoiceDelete(DeleteView): class ChoiceDelete(DeleteView):
model = Choice model = Choice
......
No preview for this file type
...@@ -16,7 +16,7 @@ Including another URLconf ...@@ -16,7 +16,7 @@ Including another URLconf
from django.conf.urls import url, include from django.conf.urls import url, include
from django.contrib import admin from django.contrib import admin
from django.contrib.auth import views from django.contrib.auth import views
from allocation import views from . import views
urlpatterns = [ urlpatterns = [
......
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login
def index1(request):
return render(request,'core/home_page.html')
\ No newline at end of file
{% extends "admin/change_form.html" %}
{% load i18n %}
{% load tag %}
{% block object-tools-items %}
{{ block.super }}
{% hello_world request.get_full_path as name %}
{% if name == True %}
<li>
<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"> Allocate</button>
</form>
</li>
{% endif %}
{% endblock %}
\ No newline at end of file
...@@ -26,4 +26,15 @@ ...@@ -26,4 +26,15 @@
{% endif %} {% endif %}
<!-- {% if request.get_full_path == "/admin/allocation/institute/1/change/" %}
<li>
<form method="POST" action="/allocation/button_action" enctype="multipart/form-data">
{% csrf_token %}
<button type="submit"> Allocate</button>
</form>
</li>
{% endif %} -->
{% endblock %} {% endblock %}
{% load static %}
<html> <html>
<head> <head>
<link rel="stylesheet" type="text/css" href="allocation/home_page.css"> <link rel="stylesheet" type="text/css" href="{% static 'allocation/home_page.css' %}" />
</head> </head>
<body> <body>
<table > <table >
<tr> <tr>
<td rowspan="2"><a class="logoText"><img src="logo.png" width="150" height="150" alt="logo"></a></td> <td rowspan="2"><a class="logoText"><img src="{% static 'allocation/logo.png' %}" width="100%" height="100%" alt="logo"></a></td>
<td style="vertical-align: bottom; padding-left:5px; padding-bottom: 2px; font-size: 20px"><a class="logoText" ><B>codeMAFIA</B></a></td> <td style="vertical-align: bottom; padding-left:5px; padding-bottom: 2px; font-size: 20px"><a class="logoText" ><B>codeMAFIA</B></a></td>
</tr> </tr>
<tr> <tr>
...@@ -17,19 +18,24 @@ ...@@ -17,19 +18,24 @@
<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: 570px; text-align: center; font-size: 30px;"> <div class="tool1" style="margin-top: 29%; text-align: center; font-size: 30px;">
</div> </div>
<div class="tool2" style="margin-top: 10px; text-align: center; font-size: 50px; color: white"> <div class="tool2" style="margin-top: 10px; text-align: center; font-size: 50px; color: white">
<a href = "/allocation/admin">
Institute login Institute login
</a>
</div> </div>
<div class="tool3" style="margin-top: 5px; text-align: center; font-size: 50px; color:white"> <div class="tool3" style="margin-top: 5px; text-align: center; font-size: 50px; color:white">
<a href="/allocation">
Applicant login Applicant login
</a>
</div> </div>
<div class="tool4" style="margin-top: 5px; text-align: center; font-size: 50px; color:white"> <div class="tool4" style="margin-top: 5px; text-align: center; font-size: 50px; color:white">
Admin login Register with us
</div> </div>
......
{% extends 'base.html' %}
{% load static %}
{% block content %}
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="myfile">
<button type="submit">Upload</button>
</form>
{% if uploaded_file_url %}
<p>File uploaded at: <a href="{{ uploaded_file_url }}">{{ uploaded_file_url }}</a></p>
{% endif %}
<p><a href="{% url 'home' %}">Return to home</a></p>
{% endblock %}
\ No newline at end of file
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