Commit c9c97d64 authored by AMAN MORESHWAR JANGDE's avatar AMAN MORESHWAR JANGDE

Phase 1 demo

parent e205f4ec
......@@ -25,15 +25,11 @@ from django.urls import path
from discussion import views
urlpatterns = [
path('admin/', admin.site.urls),
path('emp', views.emp),
path('show',views.show),
path('edit/<int:id>', views.edit),
path('update/<int:id>', views.update),
path('delete/<int:id>', views.destroy),
path('', views.default),
path('subjects/', views.show_subjects),
path('topics/<int:id>', views.show_topics),
path('available_subjects/', views.show_all_subjects),
path('topics/<str:id>', views.show_topics),
path('threads/<int:id>', views.show_threads),
path('login', views.login),
path('signup', views.signup),
......
from django.contrib import admin
# Register your models here.
from discussion.models import Employee, Person, Subject, Topic, Thread, Like, Subject_Student
from discussion.models import Person, Subject, Topic, Thread, Like, Subject_Student
admin.site.register(Subject)
admin.site.register(Employee)
admin.site.register(Person)
admin.site.register(Topic)
admin.site.register(Thread)
......
from django import forms
from discussion.models import Employee , Thread, Topic, Person
class EmployeeForm(forms.ModelForm):
class Meta:
model = Employee
fields = "__all__"
from discussion.models import Thread, Topic, Person
class ThreadForm(forms.ModelForm):
msg = forms.CharField(widget=forms.Textarea(attrs={'class' : 'form-control send-message','rows':'3', 'placeholder':'Comment...'}))
......@@ -24,7 +20,7 @@ class SignupForm(forms.ModelForm):
pid = forms.CharField(widget=forms.TextInput(attrs={'class' : 'inp-field', 'placeholder':'PID...'}))
fname = forms.CharField(widget=forms.TextInput(attrs={'class' : 'inp-field', 'placeholder':'First Name...'}))
lname = forms.CharField(widget=forms.TextInput(attrs={'class' : 'inp-field', 'placeholder':'Last name...'}))
password = forms.CharField(widget=forms.TextInput(attrs={'class' : 'inp-field', 'placeholder':'Password...'}))
password = forms.CharField(widget=forms.TextInput(attrs={'class' : 'inp-field', 'placeholder':'Password...', 'type':'password'}))
class Meta:
model = Person
......@@ -32,7 +28,7 @@ class SignupForm(forms.ModelForm):
class LoginForm(forms.ModelForm):
pid = forms.CharField(widget=forms.TextInput(attrs={'class' : 'inp-field', 'placeholder':'PID...'}))
password = forms.CharField(widget=forms.TextInput(attrs={'class' : 'inp-field', 'placeholder':'Password...'}))
password = forms.CharField(widget=forms.TextInput(attrs={'class' : 'inp-field', 'placeholder':'Password...', 'type':'password'}))
class Meta:
model = Person
......
# Generated by Django 2.0.3 on 2019-11-05 13:26
# Generated by Django 2.0.3 on 2019-11-06 07:14
from django.db import migrations, models
import django.db.models.deletion
......@@ -12,19 +12,6 @@ class Migration(migrations.Migration):
]
operations = [
migrations.CreateModel(
name='Employee',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('eid', models.CharField(max_length=20)),
('ename', models.CharField(max_length=100)),
('eemail', models.EmailField(max_length=254)),
('econtact', models.CharField(max_length=15)),
],
options={
'db_table': 'employee',
},
),
migrations.CreateModel(
name='Like',
fields=[
......
from django.db import models
class Employee(models.Model):
eid = models.CharField(max_length=20)
ename = models.CharField(max_length=100)
eemail = models.EmailField()
econtact = models.CharField(max_length=15)
class Meta:
db_table = "employee"
class Person(models.Model):
pid = models.CharField(max_length=20)
......@@ -39,6 +31,8 @@ class Subject_Student(models.Model):
class Meta:
db_table = "subject_student"
def __str__(self):
return "%s %s" % (self.student.fname, self.subject.sub_name)
class Topic(models.Model):
......
......@@ -24,7 +24,11 @@
}
.login-container
{
width: 70%;
margin: auto;
}
.login-form-container {
......
......@@ -24,7 +24,11 @@
}
.signup-container
{
width: 70%;
margin: auto;
}
.signup-form-container {
......
{% extends "base.html" %}
{% block nav-home %}<li><a href="/">Home</a></li>{% endblock %}
{% block nav-subjects %}<li ><a href="/subjects">My Subjects</a></li>{% endblock %}
{% block nav-available-subjects %}<li class="active"><a href="/available_subjects">Available Subjects</a></li>{% endblock %}
{% block body%}
<div class="container" style="margin-top:50px;">
<div style="width: 70%; margin-left: 20px;">
<h2>Available Courses</h2>
<table style="width:100%;border: solid grey 1px;box-shadow: 2px 2px;" class="table table-hover">
<thead>
<tr>
<th style="text-align: center;">Course ID</th>
<th style="text-align: center;">Course Name</th>
<th style="text-align: center;">Professor</th>
<th style="text-align: center;">Status</th>
</tr>
</thead>
<tbody>
{% for subject in subjects %}
<tr>
<td style="text-align: center;">{{ subject.sub_code }}</td>
<td style="text-align: center;">{{ subject.sub_name }}</td>
<td style="text-align: center;">{{ subject.prof.fname }} {{ subject.prof.lname }}</td>
<td style="text-align: center;"><button class="btn btn-primary">Request</button></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}
......@@ -42,11 +42,12 @@
{% block nav-home %}<li class="active"><a href="/">Home</a></li>{% endblock %}
{% if context is not None %}
{% block nav-subjects %}<li><a href="/subjects">My Subjects</a></li>{% endblock %}
{% block nav-search-subjects %}<li><a href="/subjects">Search Subjects</a></li>{% endblock %}
{% block nav-available-subjects %}<li><a href="/available_subjects">Available Subjects</a></li>{% endblock %}
{% endif %}
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="/admin"><span class="glyphicon glyphicon-wrench"></span> Admin</a></li>
{% if context is None %}
{% block nav-signup %}<li><a href="/signup"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>{%endblock%}
{%block nav-login%}<li><a href="/login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>{%endblock%}
......
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="navbar.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body style="height:1500px">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">WebSiteName</a>
</div>
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Page 1</a></li>
<li><a href="#">Page 2</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
<li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</nav>
{% extends "base.html" %}
{% block nav-home %}<li class="active"><a href="/">Home</a></li>{% endblock %}
{% block nav-subjects %}<li ><a href="/subjects">My Subjects</a></li>{% endblock %}
{% block nav-available-subjects %}<li><a href="/available_subjects">Available Subjects</a></li>{% endblock %}
{% block body%}
<div class="container" style="margin-top:70px;">
{% load static %}
<img src="{%static 'img/logo.png'%}" width="80%" height="50%" style="margin: auto; padding-left: 18%"/>
<br><br>
</body>
</html>
</div>
{% endblock %}
......@@ -10,7 +10,7 @@
<div class="container message-wrap " style="margin-top:50px">
<p>
<h3>
Topics in Subject
Topics in {{sub_code}}
</h3>
</p>
<div class="list-view">
......
......@@ -13,9 +13,11 @@
<h2 style="margin-top:50px;text-align: center;">Login</h2>
<div class="login-container">
<form action="/login" method="post" class="login-form">
<h2 style="margin-top:50px;text-align: center;">Login</h2>
<form action="/login" method="post" class="login-form">
{% csrf_token %}
<div class="login-form-container">
......@@ -36,6 +38,10 @@
</div>
</form>
</form>
</div>
{% endblock %}
......@@ -11,9 +11,10 @@
{%block nav-login%}<li><a href="/login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>{%endblock%}
{% block body%}
<h2 style="margin-top:50px;text-align:center;">Signup</h2>
<div class="signup-container">
<h2 style="margin-top:50px;text-align:center;">Signup</h2>
<form action="/signup" method="post" class="signup-form">
<form action="/signup" method="post" class="signup-form">
{% csrf_token %}
<div class="signup-form-container">
......@@ -37,6 +38,8 @@
</div>
</form>
</form>
</div>
{% endblock %}
......@@ -3,29 +3,32 @@
{% block nav-home %}<li><a href="/">Home</a></li>{% endblock %}
{% block nav-subjects %}<li class="active"><a href="/subjects">My Subjects</a></li>{% endblock %}
{% block nav-search-subjects %}<li><a href="/subjects">Search Subjects</a></li>{% endblock %}
{% block nav-search-subjects %}<li><a href="/subjects">Available Subjects</a></li>{% endblock %}
{% block body%}
<div class="container" style="margin-top:50px">
<div class="container" style="margin-top:50px;">
<div style="width: 70%; margin: auto;">
<h2>My Courses</h2>
<ul>
<table style="width:100%">
<table style="width:100%;border: solid grey 1px;box-shadow: 2px 2px;" class="table table-hover">
<thead>
<tr>
<th>Course ID</th>
<th>Course Name</th>
<th style="text-align: center;">Course ID</th>
<th style="text-align: center;">Course Name</th>
<!-- <th>Professor</th> -->
</tr>
</thead>
<tbody>
{% for sub_stu in subject_student %}
<tr>
<td><a href="/topics/{{ sub_stu.subject.sub_code }}">{{ sub_stu.subject.sub_code }} </a></td>
<td>{{ sub_stu.subject.sub_name }}</td>
<td style="text-align: center;"><a href="/topics/{{ sub_stu.subject.sub_code }}">{{ sub_stu.subject.sub_code }} </a></td>
<td style="text-align: center;">{{ sub_stu.subject.sub_name }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</ul>
</div>
</div>
{% endblock %}
from django.shortcuts import render, redirect
from discussion.forms import EmployeeForm , ThreadForm, TopicForm, SignupForm, LoginForm
from discussion.models import Employee, Subject_Student, Person, Subject, Topic, Thread, Person
# Create your views here.
def emp(request):
if request.method == "POST":
form = EmployeeForm(request.POST)
if form.is_valid():
try:
form.save()
return redirect('/show')
except:
pass
else:
form = EmployeeForm()
return render(request,'index.html',{'form':form})
def show(request):
employees = Employee.objects.all()
return render(request,"show.html",{'employees':employees})
def edit(request, id):
employee = Employee.objects.get(id=id)
return render(request,'edit.html', {'employee':employee})
def update(request, id):
employee = Employee.objects.get(id=id)
form = EmployeeForm(request.POST, instance = employee)
if form.is_valid():
form.save()
return redirect("/show")
return render(request, 'edit.html', {'employee': employee})
def destroy(request, id):
employee = Employee.objects.get(id=id)
employee.delete()
return redirect("/show")
from discussion.forms import ThreadForm, TopicForm, SignupForm, LoginForm
from discussion.models import Subject_Student, Person, Subject, Topic, Thread, Person
def login(request):
invalid_user = False
......@@ -70,7 +39,7 @@ def logout(request):
del request.session['session_context']
except:
pass
return render(request, 'base.html')
return render(request, 'default.html')
def signup(request):
if request.method == "POST":
......@@ -96,7 +65,7 @@ def default(request):
except:
context = None
return render(request, 'base.html' ,{'context':context})
return render(request, 'default.html' ,{'context':context})
def show_subjects(request):
context = request.session['session_context']
......@@ -107,6 +76,12 @@ def show_subjects(request):
subject_student = Subject_Student.objects.filter(student = person)
return render(request,"subjects.html",{'subject_student':subject_student, 'context':context})
def show_all_subjects(request):
context = request.session['session_context']
subjects = Subject.objects.all()
return render(request,"available_subjects.html",{'subjects':subjects, 'context':context})
def show_topics(request, id):
context = request.session['session_context']
try:
......
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