Commit d98cf560 authored by KUNAL GOYAL's avatar KUNAL GOYAL

institute login

parents dbd1786b 0d405535
# -*- coding: utf-8 -*-
<<<<<<< HEAD
# Generated by Django 1.11.5 on 2017-10-21 06:24
=======
# Generated by Django 1.11.5 on 2017-10-17 06:12
>>>>>>> 0d4055356852c072dfd6fd78966f4318a0d032bd
from __future__ import unicode_literals
from django.db import migrations, models
......
from __future__ import unicode_literals
from django.db import models
# import math
# import CsvModel
import csv
import os
class Institute(models.Model):
name=models.CharField(max_length=200)
......
<html>
<head>
<link rel="stylesheet" type="text/css" href="core/home_page.css">
</head>
<body>
<table >
<tr>
<td rowspan="2"><a class="logoText"><img src="logo.png" width="150" height="150" 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: 570px; text-align: center; font-size: 30px;">
</div>
<div class="tool2" style="margin-top: 10px; text-align: center; font-size: 50px; color: white">
Institute login
</div>
<div class="tool3" style="margin-top: 5px; text-align: center; font-size: 50px; color:white">
Applicant login
</div>
<div class="tool4" style="margin-top: 5px; text-align: center; font-size: 50px; color:white">
Admin login
</div>
</body>
</html>
\ No newline at end of file
......@@ -13,6 +13,13 @@ urlpatterns = [
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'^import_db$', views.import_db, name='import_db1'),
url(r'^applicant_make$', views.applicant_make, name='applicant_make'),
#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
from django.shortcuts import render
from django.http import HttpResponse
from django.contrib.auth import authenticate
from django.contrib.auth.decorators import login_required
......@@ -10,6 +9,14 @@ from django.forms import modelformset_factory
from django.views import generic
from django.views.generic.edit import CreateView
from allocation.models import Choice
from allocation.models import Applicant
from django.shortcuts import render, redirect
from django.conf import settings
from django.core.files.storage import FileSystemStorage
from django.contrib.auth import authenticate, login
from django import forms
import csv
# @login_required(login_url='/admin/login')
# def index(request): #for /allocation
# applicant=Applicant.objects.filter(name=request.user.username)[0]
......@@ -19,6 +26,51 @@ from django.views.generic.edit import CreateView
# form = ArticleForm(instance=applicant)
# return render(request, 'allocation/index.html', {'applicant': applicant, 'form': form})
def index(request):
return HttpResponse("Hello, world. You're at the allocation index.")
def index1(request):
return render(request,'core/home_page.html')
def home(request):
documents = Document.objects.all()
return render(request, 'core/home.html', { 'documents': documents })
return HttpResponse("On home")
def import_db(request):
if request.method == "POST":
csvfile = request.FILES['myfile']
file_data = csvfile.read().decode("utf-8")
lines = file_data.split("\n")
user_name = request.user.username
institute = Institute.objects.filter(name=user_name)[0]
for line in lines:
line = line.split(',')
# tmp = Choice.objects.create(choice_name=line[0],capacity=line[1])
tmp = institute.choices.create(choice_name=line[0],capacity=line[1])
tmp.save()
return HttpResponse("successful")
return HttpResponse("Error")
def applicant_make(request):
if request.method == "POST":
csvfile = request.FILES['myfile']
file_data = csvfile.read().decode("utf-8")
user_name = request.user.username
institute = Institute.objects.filter(name=user_name)[0]
lines = file_data.split("\n")
for line in lines:
line = line.split(',')
# tmp = Applicant.objects.create(name = line[0],rank=line[1])
tmp = institute.applicants.create(name = line[0],rank = line[1])
tmp.save()
user = User.objects.create_user(username=line[2],email=line[3],password=line[4])
user.is_staff = True
user.save()
return HttpResponse("successful")
return HttpResponse("Error")
AppFormset = modelformset_factory(Application,fields=("choice", "priority" ), extra=5)
......@@ -57,6 +109,7 @@ def admin1(request):
return render(request, 'allocation/admin1.html',{'institute': institute})
<<<<<<< HEAD
class ChoiceListView(generic.ListView):
model = Choice
def get_context_data(self, **kwargs):
......@@ -98,6 +151,15 @@ class ApplicantDetailView(generic.DetailView):
class ChoiceCreateView(CreateView):
model = Choice
fields = ['choice_name', 'capacity', 'institute']
=======
# 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')
>>>>>>> 0d4055356852c072dfd6fd78966f4318a0d032bd
......
......@@ -16,8 +16,11 @@ 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
urlpatterns = [
url(r'^allocation/', include('allocation.urls')),
url(r'^admin/', admin.site.urls),
url(r'^$',views.index1,name='index1'),
]
{% extends "admin/change_list.html" %}
{% load i18n %}
{% block object-tools-items %}
{{ block.super }}
{% if request.get_full_path == "/admin/allocation/choice/" %}
<li>
<form method="POST" action="/allocation/import_db" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="myfile">
<button type="submit">Upload</button>
</form>
</li>
{% endif %}
{% if request.get_full_path == "/admin/allocation/applicant/" %}
<li>
<form method="POST" action="/allocation/applicant_make" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="myfile">
<button type="submit">Upload</button>
</form>
</li>
{% 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;
}
.tool1 {
margin-top: 680px;
background-color: green;
}
.tool2 {
margin-top: 700px;
background-color: #5DBCD2;
}
.tool3 {
margin-top: 720px;
background-color: #5DBCD2;
}
.tool4 {
margin-top: 720px;
background-color: #5DBCD2;
}
\ No newline at end of file
<html>
<head>
<link rel="stylesheet" type="text/css" href="allocation/home_page.css">
</head>
<body>
<table >
<tr>
<td rowspan="2"><a class="logoText"><img src="logo.png" width="150" height="150" 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: 570px; text-align: center; font-size: 30px;">
</div>
<div class="tool2" style="margin-top: 10px; text-align: center; font-size: 50px; color: white">
Institute login
</div>
<div class="tool3" style="margin-top: 5px; text-align: center; font-size: 50px; color:white">
Applicant login
</div>
<div class="tool4" style="margin-top: 5px; text-align: center; font-size: 50px; color:white">
Admin login
</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
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