Commit 33dc204e authored by amanjain2898@gmail.com's avatar amanjain2898@gmail.com

upload+univ_logins

parents f2b74fa1 67cd18ef
{% load i18n static %}<!DOCTYPE html>
{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %}
<html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
<head>
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% static "admin/css/base.css" %}{% endblock %}" />
{% block extrastyle %}{% endblock %}
{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}" />{% endif %}
{% block extrahead %}{% endblock %}
{% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{% endblock %}
</head>
{% load i18n %}
<body class="{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}"
data-admin-utc-offset="{% now "Z" %}">
<!-- Container -->
<div id="container">
{% if not is_popup %}
<!-- Header -->
<div id="header">
<div id="branding">
{% block branding %}{% endblock %}
</div>
{% block usertools %}
{% if has_permission %}
<div id="user-tools">
{% block welcome-msg %}
{% trans 'Welcome,' %}
<strong>{% firstof user.get_short_name user.get_username %}</strong>.
{% endblock %}
{% block userlinks %}
{% if site_url %}
<a href="{{ site_url }}">{% trans 'View site' %}</a> /
{% endif %}
{% if user.is_active and user.is_staff %}
{% url 'django-admindocs-docroot' as docsroot %}
{% if docsroot %}
<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> /
{% endif %}
{% endif %}
{% if user.has_usable_password %}
<a href="{% url 'admin:password_change' %}">{% trans 'Change password' %}</a> /
{% endif %}
<a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
{% endblock %}
</div>
{% endif %}
{% endblock %}
{% block nav-global %}{% endblock %}
</div>
<!-- END Header -->
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
{% if title %} &rsaquo; {{ title }}{% endif %}
</div>
{% endblock %}
{% endif %}
{% block messages %}
{% if messages %}
<ul class="messagelist">{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message|capfirst }}</li>
{% endfor %}</ul>
{% endif %}
{% endblock messages %}
<!-- Content -->
<div id="content" class="{% block coltype %}colM{% endblock %}">
{% block pretitle %}{% endblock %}
{% block content_title %}{% if title %}<h1>{{ title }}</h1>{% endif %}{% endblock %}
{% block content %}
{% block object-tools %}{% endblock %}
{{ content }}
{% endblock %}
{% block sidebar %}{% endblock %}
<br class="clear" />
</div>
<!-- END Content -->
{% block footer %}<div id="footer"></div>{% endblock %}
</div>
<!-- END Container -->
</body>
</html>
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-17 06:12
# Generated by Django 1.11.5 on 2017-10-21 10:18
from __future__ import unicode_literals
from django.db import migrations, models
......
......@@ -7,7 +7,7 @@
bottom: 0;
left: 0;
right: 0;
/*z-index: 1;*/
z-index: -1;
background-image: url('BG.png');
/*background-size: 2000px 700px;*/
background-size: 100% 75%;
......@@ -26,19 +26,23 @@
.tool1 {
margin-top: 680px;
background-color: green;
z-index: 1;
}
.tool2 {
margin-top: 700px;
background-color: #5DBCD2;
z-index: 1;
}
.tool3 {
margin-top: 720px;
background-color: #5DBCD2;
z-index: 1;
}
.tool4 {
margin-top: 720px;
background-color: #5DBCD2;
z-index: 1;
}
\ No newline at end of file
{% 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 %}
{% block usertools %}
<div id="user-tools">
{% block welcome-msg %}
{% trans 'Welcome,' %}
<!-- <strong>{{ university.name }}</strong>. -->
<strong> {{institute.name}}</strong>.
{% endblock %}
{% block userlinks %}
{% if user.has_usable_password %}
......@@ -14,7 +20,30 @@
{% endif %}
<a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
{% endblock %}
</div>
{% endblock %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'allocation:admin1' %}">{% trans 'Home' %}</a>
</div>
{% endblock %}
{% block content %}
<h1></h1>
<p style="font-size: 30px;"><a href="{% url 'allocation:applicant_list' %}">Applicants</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 %}
{% extends "allocation/admin1.html" %}
{% load i18n admin_urls static admin_list %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'allocation:admin1' %}">{% trans 'Home' %}</a>
&rsaquo; <a href="{% url 'allocation:applicant_list' %}">{% trans 'Applicants' %}</a>
&rsaquo; {{ applicant.name }}
</div>
{% endblock %}
{% block content %}
{% if applicant.institute.name == request.user.username %}
<p><b>Name:</b> {{ applicant.name }}</p>
<p><b>Rank:</b> {{ applicant.rank }}</p>
<p><b>Allotted Choice:</b> {{ applicant.alloted_choice }}
{% else %}
Unauthorised access
{% endif %}
{% endblock %}
{% extends "allocation/admin1.html" %}
{% load i18n admin_urls static admin_list %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'allocation:admin1' %}">{% trans 'Home' %}</a>
&rsaquo; Applicants
</div>
{% endblock %}
{% block content %}
<h1>Applicants</h1>
{% if applicant_list %}
<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 %}
<li>
<a href="{% url 'allocation:applicant-detail' applicant.pk %}">{{ applicant.name }}</a>
</li>
{% endfor %}
</ul>
{% 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>
{% endif %}
{% endblock %}
{% extends "allocation/admin1.html" %}
{% load i18n admin_urls static admin_list %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'allocation:admin1' %}">{% trans 'Home' %}</a>
&rsaquo; <a href="{% url 'allocation:choice_list' %}">{% trans 'Choices' %}</a>
&rsaquo; {{ choice.choice_name }}
</div>
{% endblock %}
{% block content %}
{% if choice.institute.name == request.user.username %}
<form action="" method="post">{% csrf_token %}
<p>Are you sure you want to delete "{{ object }}"?</p>
<input type="submit" value="Confirm" />
</form>
{% else %}
Unauthorised access
{% endif %}
{% endblock %}
{% extends "allocation/admin1.html" %}
{% load i18n admin_urls static admin_list %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'allocation:admin1' %}">{% trans 'Home' %}</a>
&rsaquo; <a href="{% url 'allocation:choice_list' %}">{% trans 'Choices' %}</a>
&rsaquo; {{ choice.choice_name }}
</div>
{% endblock %}
{% block content %}
{% if choice.institute.name == request.user.username %}
<p><b>Choice name:</b> {{ choice.choice_name }}</p>
<p><b>Capacity:</b> {{ choice.capacity }}</p>
<form action="{% url 'allocation:choice-update' choice.pk %}">
<input type="submit" value="Update" />
</form>
<form action="{% url 'allocation:choice-delete' choice.pk %}">
<input style="background-color: red;" type="submit" value="Delete" />
</form>
{% else %}
Unauthorised access
{% endif %}
{% endblock %}
{% extends "allocation/admin1.html" %}
{% load i18n admin_urls static admin_list %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'allocation:admin1' %}">{% trans 'Home' %}</a>
&rsaquo; Choices
</div>
{% endblock %}
{% block content %}
<h1>Choice List</h1>
{% if choice_list %}
<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 %}
<li>
<a href="{% url 'allocation:choice-detail' choice.pk %}">{{ choice.choice_name }}</a>
</li>
{% endfor %}
</ul>
{% 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>
{% endif %}
</div>
{% endblock %}
{% extends "allocation/admin1.html" %}
{% load i18n admin_urls static admin_list %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'allocation:admin1' %}">{% trans 'Home' %}</a>
&rsaquo; <a href="{% url 'allocation:choice_list' %}">{% trans 'Choices' %}</a>
&rsaquo; {{ choice.choice_name }}
</div>
{% endblock %}
{% block content %}
{% if choice.institute.name == request.user.username %}
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Update" />
</form>
{% else %}
Unauthorised access
{% endif %}
{% endblock %}
.container { position: relative; }
.container{
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: -1;
/*background-image: url('BG.png');*/
background-size: 2000px 700px;
background-repeat: no-repeat;
background-attachment: fixed;
opacity: 0.60;
}
.content {
position: relative;
margin-top: 300px;
font-size: 60px;
opacity: 20;
z-index: 1;
}
.tool1 {
margin-top: 680px;
background-color: green;
z-index: 1;
}
.tool2 {
margin-top: 700px;
background-color: #5DBCD2;
z-index: 2;
}
.tool3 {
margin-top: 720px;
background-color: #5DBCD2;
}
.tool4 {
margin-top: 720px;
background-color: #5DBCD2;
}
\ No newline at end of file
{% load static %}
<html>
<head>
<link rel="stylesheet" type="text/css" href="{% static 'allocation/home_page.css' %}" />
</head>
<body>
<table >
<tr>
<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>
</tr>
<tr>
<td style="vertical-align: top; padding-left:20px; font-size:20px"><a class="tagLine" ><B><I>the journey begins... </I></B></a></td>
</tr>
</table>
<div class="container">
<div class="content"><h1 align="center" style="color:black">General Allocation Portal</h1></div>
</div>
<div class="tool1" style="margin-top: 460px; text-align: center; font-size: 30px;">
</div>
<div class="tool2" style="margin-top: 10px; text-align: center; font-size: 50px; color: white">
<a href = "/allocation/admin">
Institute login
</a>
</div>
<div class="tool3" style="margin-top: 5px; text-align: center; font-size: 50px; color:white">
<a href="/allocation">
Applicant login
</a>
</div>
<div class="tool4" style="margin-top: 5px; text-align: center; font-size: 50px; color:white">
Register with us
</div>
</body>
</html>
\ No newline at end of file
{% 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
......@@ -8,11 +8,19 @@ urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^submit$', views.submit, name='submit'),
url(r'^admin$', views.admin1, name='admin1'),
url(r'^import_db$', views.import_db, name='import_db1'),
url(r'^admin/choices$', views.ChoiceListView.as_view(), name='choice_list'),
url(r'^admin/applicants$', views.ApplicantListView.as_view(), name='applicant_list'),
url(r'^choice/(?P<pk>\d+)$', views.ChoiceDetailView.as_view(), name='choice-detail'),
url(r'^applicant/(?P<pk>\d+)$', views.ApplicantDetailView.as_view(), name='applicant-detail'),
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+)/delete$', views.ChoiceDelete.as_view(), name='choice-delete'),
url(r'^choice_make$', views.choice_make, name='choice_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/applicants$', views.ApplicantListView.as_view(), name='applicant_list'),
#url(r'^login/$', auth_views.login,name='login'),
#url(r'^logout/$', auth_views.logout, name='logout1'),
]
\ No newline at end of file
......@@ -7,6 +7,8 @@ from allocation.models import *
from django.forms import modelform_factory
from django.forms import modelformset_factory
from django.views import generic
from django.views.generic.edit import *
from allocation.models import Choice
from allocation.models import Applicant
from django.shortcuts import render, redirect
......@@ -14,8 +16,11 @@ from django.conf import settings
from django.core.files.storage import FileSystemStorage
from django.contrib.auth import authenticate, login
from django import forms
from alloc import *
import csv
from django.urls import reverse_lazy
from alloc import *
# @login_required(login_url='/admin/login')
# def index(request): #for /allocation
# applicant=Applicant.objects.filter(name=request.user.username)[0]
......@@ -25,18 +30,22 @@ import csv
# form = ArticleForm(instance=applicant)
# return render(request, 'allocation/index.html', {'applicant': applicant, 'form': form})
def index1(request):
return render(request,'core/home_page.html')
def button_action(request):
value = request.POST["prikey"]
value = int(value.split('/')[-3])
name = Institute.objects.get(pk=value).name
allocator(name)
# value = request.POST["prikey"]
# value = int(value.split('/')[-3])
# name = Institute.objects.get(pk=value).name
# allocator(name)
# return HttpResponse("success")
institute=request.user.username
allocator(institute)
return HttpResponse("success")
def import_db(request):
def home(request):
documents = Document.objects.all()
return render(request, 'core/home.html', { 'documents': documents })
return HttpResponse("On home")
def choice_make(request):
if request.method == "POST":
csvfile = request.FILES['myfile']
file_data = csvfile.read().decode("utf-8")
......@@ -102,21 +111,63 @@ def submit(request):
instances = formset.save()
return HttpResponse("successful")
@login_required(login_url='/admin/login')
def admin1(request):
return render(request, 'allocation/admin1.html')
# class ChoiceListView(generic.ListView):
# model = Choice
# queryset = Choice.objects.filter(institute='IITB')
# class ApplicantListView(generic.ListView):
# model = Applicant
# queryset = Applicant.objects.filter(institute_name='IITB')
institute=Institute.objects.filter(name=request.user.username)[0]
return render(request, 'allocation/admin1.html',{'institute': institute})
class ChoiceListView(generic.ListView):
model = Choice
def get_context_data(self, **kwargs):
institute=Institute.objects.filter(name=self.request.user.username)[0]
context = super(ChoiceListView, self).get_context_data(**kwargs)
context['institute'] = institute
return context
def get_queryset(self):
institute=Institute.objects.filter(name=self.request.user.username)[0]
return Choice.objects.filter(institute__name=institute.name)
class ApplicantListView(generic.ListView):
model = Applicant
def get_context_data(self, **kwargs):
institute=Institute.objects.filter(name=self.request.user.username)[0]
context = super(ApplicantListView, self).get_context_data(**kwargs)
context['institute'] = institute
return context
def get_queryset(self):
institute=Institute.objects.filter(name=self.request.user.username)[0]
return Applicant.objects.filter(institute__name=institute.name)
class ChoiceDetailView(generic.DetailView):
model = Choice
def get_context_data(self, **kwargs):
institute=Institute.objects.filter(name=self.request.user.username)[0]
context = super(ChoiceDetailView, self).get_context_data(**kwargs)
context['institute'] = institute
return context
class ApplicantDetailView(generic.DetailView):
model = Applicant
def get_context_data(self, **kwargs):
institute=Institute.objects.filter(name=self.request.user.username)[0]
context = super(ApplicantDetailView, self).get_context_data(**kwargs)
context['institute'] = institute
return context
class ChoiceCreateView(CreateView):
model = Choice
fields = ['choice_name', 'capacity', 'institute']
class ChoiceUpdate(UpdateView):
model = Choice
fields = ['choice_name','capacity']
template_name_suffix = '_update'
success_url = 'allocation:choice_list'
class ChoiceDelete(DeleteView):
model = Choice
success_url = reverse_lazy('allocation:choice_list')
No preview for this file type
No preview for this file type
......@@ -16,7 +16,7 @@ Including another URLconf
from django.conf.urls import url, include
from django.contrib import admin
from django.contrib.auth import views
from allocation import views
from . import views
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
......@@ -7,8 +7,8 @@
bottom: 0;
left: 0;
right: 0;
/*z-index: 1;*/
background-image: url('BG.png');
z-index: -1;
/*background-image: url('BG.png');*/
background-size: 2000px 700px;
background-repeat: no-repeat;
background-attachment: fixed;
......@@ -20,16 +20,19 @@
margin-top: 300px;
font-size: 60px;
opacity: 20;
z-index: 1;
}
.tool1 {
margin-top: 680px;
background-color: green;
z-index: 1;
}
.tool2 {
margin-top: 700px;
background-color: #5DBCD2;
z-index: 2;
}
.tool3 {
......
......@@ -21,16 +21,21 @@
<div class="tool1" style="margin-top: 460px; text-align: center; font-size: 30px;">
</div>
<div class="tool2" style="margin-top: 10px; text-align: center; font-size: 50px; color: white">
<a href = "/allocation/admin">
Institute login
</a>
</div>
<div class="tool3" style="margin-top: 5px; text-align: center; font-size: 50px; color:white">
<a href="/allocation">
Applicant login
</a>
</div>
<div class="tool4" style="margin-top: 5px; text-align: center; font-size: 50px; color:white">
Admin login
Register with us
</div>
......
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