Commit 4d10f2c9 authored by EASHAN GUPTA's avatar EASHAN GUPTA

Institute reg

parent 787c83d5
......@@ -20,12 +20,17 @@ class AllotedChoiceToAppInLine(admin.TabularInline):
class ApplicantAdmin(admin.ModelAdmin):
fields = ['name', 'rank','institute']
list_display=['name','institute']
inlines = [ChoiceInline, AllotedChoiceToAppInLine]
# class ChoiceAdmin(admin.ModelAdmin):
# fields=['choice_name', 'capacity']
# inlines=[UnivChoiceInLine]
class InstituteAdmin(admin.ModelAdmin):
fields=['name']
admin.site.register(Institute)
admin.site.register(Choice)
class ChoiceAdmin(admin.ModelAdmin):
fields=['choice_name', 'capacity','institute']
list_display=['choice_name', 'capacity', 'institute']
# inlines=[UnivChoiceInLine]
admin.site.register(Institute, InstituteAdmin)
admin.site.register(Choice, ChoiceAdmin)
admin.site.register(Applicant, ApplicantAdmin)
\ No newline at end of file
from django import forms
from allocation.models import *
from django.forms import ModelForm
# from registration.forms import RegistrationForm
# import re
from django.contrib.auth.models import User
# from django.core.exceptions import ObjectDoesNotExist
from django import forms
from django.contrib.auth.forms import UserCreationForm
class InstiForm(UserCreationForm):
# name = forms.DateField(help_text='Required. Format: YYYY-MM-DD')
class Meta:
model = User
fields = ['username', 'password1', 'password2', ]
# username = forms.CharField(label='Username', max_length=30)
# email = forms.EmailField(label='Email')
# class Meta:
# model = Institute
# fields=['name',]
# # widgets=
# password1 = forms.CharField(label='Password', widget=forms.PasswordInput())
# password2 = forms.CharField(label='Password (Again)', widget=forms.PasswordInput())
# def clean_password2(self):
# if 'password1' in self.cleaned_data:
# password1 = self.cleaned_data['password1']
# password2 = self.cleaned_data['password2']
# if password1 == password2:
# return password2
# raise forms.ValidationError('Passwords do not match.')
# def clean_username(self):
# username = self.cleaned_data['name']
# if not re.search(r'^\w+$', username):
# raise forms.ValidationError('Username can only contain alphanumeric characters and the underscore.')
# try:
# User.objects.get(username=username)
# except ObjectDoesNotExist:
# return username
# raise forms.ValidationError('Username is already taken.')
# class PreferenceForm(forms.Form):
# name = forms.CharField()
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-22 19:07
# Generated by Django 1.11.5 on 2017-10-25 13:03
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
......@@ -21,8 +22,8 @@ class Migration(migrations.Migration):
],
options={
'verbose_name': 'Allocated Choice',
'verbose_name_plural': 'Allocated Choice',
'ordering': ['applicant__rank'],
'verbose_name_plural': 'Allocated Choice',
},
),
migrations.CreateModel(
......@@ -30,14 +31,14 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('rank', models.IntegerField()),
('rank', models.IntegerField(validators=[django.core.validators.MinValueValidator(1)])),
],
),
migrations.CreateModel(
name='Application',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('priority', models.IntegerField()),
('priority', models.IntegerField(validators=[django.core.validators.MinValueValidator(1)])),
('applicant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='allocation.Applicant')),
],
options={
......
......@@ -8,11 +8,18 @@ import os
class Institute(models.Model):
name=models.CharField(max_length=200)
# username=models.CharField(max_length=200)
# email=models.EmailField(max_length=200)
def __str__(self):
return self.name
class Meta:
verbose_name='Institute'
verbose_name_plural='Institutes'
# @receiver(post_save, sender=User)
# def update_user_profile(sender, instance, created, **kwargs):
# if created:
# Profile.objects.create(user=instance)
# instance.profile.save()
class Choice(models.Model):
choice_name = models.CharField(max_length=200)
......
{% extends 'admin/base.html' %}
{% block content %}
<h2>Sign up</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Sign up</button>
</form>
{% endblock %}
......@@ -18,6 +18,7 @@ urlpatterns = [
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'^register/$', views.signup),
#url(r'^admin/choices$', views.ChoiceListView.as_view(), name='choice_list'),
#url(r'^admin/applicants$', views.ApplicantListView.as_view(), name='applicant_list'),
......
......@@ -7,9 +7,6 @@ from allocation.models import *
from django.forms import modelformset_factory, formset_factory, modelform_factory, ModelForm
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, get_object_or_404
from django.conf import settings
from django.core.files.storage import FileSystemStorage
......@@ -17,7 +14,7 @@ from django.contrib.auth import authenticate, login
from django import forms
import csv
from django.urls import reverse_lazy
from allocation.forms import *
from alloc import *
# @login_required(login_url='/admin/login')
......@@ -29,6 +26,30 @@ from alloc import *
# form = ArticleForm(instance=applicant)
# return render(request, 'allocation/index.html', {'applicant': applicant, 'form': form})
# def register_page(request):
# if request.method == 'POST':
# form = InstiForm(request.POST)
# if form.is_valid():
# user = User.objects.create_user(username=form.cleaned_data['name'],password=form.cleaned_data['password1'],email=form.cleaned_data['email'])
# return HttpResponseRedirect('/')
# form = InstiForm()
# variables = RequestContext(request, {'form': form})
# return render_to_response('registration/register.html',variables)
def signup(request):
if request.method == 'POST':
form = InstiForm(request.POST)
if form.is_valid():
user = form.save()
user.is_staff=True
user.save()
new_insti=Institute(name=user.username)
new_insti.save()
return HttpResponseRedirect('/allocation/admin')
else:
form = InstiForm()
return render(request, 'registration/register.html', {'form': form})
def button_action(request):
# value = request.POST["prikey"]
# value = int(value.split('/')[-3])
......
No preview for this file type
......@@ -17,10 +17,13 @@ from django.conf.urls import url, include
from django.contrib import admin
from django.contrib.auth import views
from . import views
from allocation.models import *
from allocation.forms import *
# from allocation.views import *
urlpatterns = [
url(r'^allocation/', include('allocation.urls')),
url(r'^admin/', admin.site.urls),
url(r'^$',views.index1,name='index1'),
# url(r'^register/', allocation.views.signup),
]
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