Skip to content
Snippets Groups Projects
Commit 0d9788a1 authored by hiruthikj's avatar hiruthikj
Browse files

login and home

parent b6175e6e
No related branches found
No related tags found
No related merge requests found
Showing
with 76 additions and 112 deletions
No preview for this file type
No preview for this file type
...@@ -59,7 +59,7 @@ ROOT_URLCONF = 'book_management_system.urls' ...@@ -59,7 +59,7 @@ ROOT_URLCONF = 'book_management_system.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [], 'DIRS': [str(BASE_DIR.joinpath('templates'))],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
...@@ -136,4 +136,5 @@ STATICFILES_DIRS = [ ...@@ -136,4 +136,5 @@ STATICFILES_DIRS = [
MEDIA_URL = '/media/' MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
LOGIN_URL = '/students/login/' LOGIN_URL = '/accounts/login/'
LOGIN_REDIRECT_URL = '/online_books/home/'
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
from django.conf import settings from django.conf import settings
from django.conf.urls.static import static from django.conf.urls.static import static
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('booksite/', include('online_books.urls')), path('accounts/', include('django.contrib.auth.urls')),
path('online_books/', include('online_books.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
\ No newline at end of file
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
# Generated by Django 3.1.4 on 2020-12-26 10:52 # Generated by Django 3.1.4 on 2020-12-27 12:45
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
...@@ -31,9 +31,9 @@ class Migration(migrations.Migration): ...@@ -31,9 +31,9 @@ class Migration(migrations.Migration):
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('book_title', models.CharField(max_length=100)), ('book_title', models.CharField(max_length=100)),
('description', models.TextField(max_length=400)), ('description', models.TextField(blank=True, max_length=400, null=True)),
('price', models.FloatField(help_text='In rupees (₹)')), ('price', models.FloatField(blank=True, help_text='In rupees (₹)', null=True)),
('author_fk', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='online_books.author')), ('author_fk', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='online_books.author')),
('genres', models.ManyToManyField(to='online_books.Genre')), ('genres', models.ManyToManyField(to='online_books.Genre')),
], ],
), ),
......
No preview for this file type
...@@ -14,10 +14,11 @@ class Author(models.Model): ...@@ -14,10 +14,11 @@ class Author(models.Model):
class Book(models.Model): class Book(models.Model):
book_title = models.CharField(max_length=100) book_title = models.CharField(max_length=100)
author_fk = models.ForeignKey('Author', on_delete=models.CASCADE) author_fk = models.ForeignKey('Author', on_delete=models.CASCADE, null=True, blank=True)
genres = models.ManyToManyField('Genre') genres = models.ManyToManyField('Genre')
description = models.TextField(max_length=400, null=True, blank=True) description = models.TextField(max_length=400, null=True, blank=True)
price = models.FloatField(help_text="In rupees (₹)") price = models.FloatField(help_text="In rupees (₹)", null=True, blank=True)
def __str__(self): def __str__(self):
return self.book_title return self.book_title
/* body, html {
height: 100%;
background-repeat: no-repeat;
background-repeat: repeat;
background-image: linear-gradient(rgb(104, 145, 162), rgb(12, 97, 33));
background-attachment: fixed;
} */
#MyNav{
margin-bottom: 10px;
}
#univLogo{
color: darkorange;
}
body, html {
height: 100%;
background-repeat: no-repeat;
background-attachment: fixed;
/* background-color: #85FFBD;
background-image: linear-gradient(45deg, #85FFBD 0%, #FFFB7D 100%); */
/* background-image: radial-gradient( circle farthest-corner at 10% 20%, rgba(153,103,186,1) 41.2%, rgba(0,113,227,1) 90% ); */
background-image: radial-gradient( circle farthest-corner at 10% 20%, rgba(147,230,241,1) 0%, rgba(145,192,241,1) 45.5% );
}
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}Default Title{% endblock %}</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-social/5.1.1/bootstrap-social.min.css" integrity="sha512-f8mUMCRNrJxPBDzPJx3n+Y5TC5xp6SmStstEfgsDXZJTcxBakoB5hvPLhAfJKa9rCvH+n3xpJ2vQByxLk4WP2g==" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA==" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'online_books/css/base.css' %}">
{% block head %}{% endblock %}
</head>
<body>
{% block nav %}
<nav class="navbar navbar-expand-lg navbar-extend-sm navbar-dark bg-dark" id="MyNav">
<div class="container">
<a class="navbar-brand" id="univLogo" href="{% url 'stud_app:home' username %}"><span class="fas fa-university"> Online Exam System</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#Navbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id='Navbar'>
<div class="navbar-nav">
<a class="nav-item nav-link {% if current_page == 'home' %}active{% endif %}" href="{% url 'stud_app:home' username %}"><span class="fas fa-user-graduate"></span> My Details</a>
<a class="nav-item nav-link {% if current_page == 'courses' %}active{% endif %}" href="{% url 'stud_app:courses' username %}"><span class="fas fa-book-open"></span> Courses</a>
<a class="nav-item nav-link {% if current_page == 'exams' %}active{% endif %}" href="{% url 'stud_app:exams' username %}"><span class="fas fa-edit"></span> Exams</a>
<a class="nav-item nav-link {% if current_page == 'scores' %}active{% endif %}" href="{% url 'stud_app:scores' username %}"><span class="fas fa-file-alt"></span> Scores</a>
</div>
<div class="navbar-nav ml-auto">
<a class="nav-item nav-link ml-auto" href="{% url 'stud_app:logout' %}"><span class="fas fa-sign-out-alt"></span> Log Out</a>
</div>
</div>
</div>
</nav>
{% endblock %}
<!-- {% block breadcrumb %}
<ol class="breadcrumb container">
<li class="breadcrumb-item active"><a href="#">Home</a></li>
</ol>
{% endblock %} -->
{% block content %}
{% endblock %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
from django.conf.urls import url,include from django.conf.urls import url,include
from django.urls import path from django.urls import path
from . import views from . import views
# from .forms import StudentLoginForm
from django.contrib.auth.views import * from django.contrib.auth.views import *
#LoginView,LogoutView,PasswordResetView,PasswordResetDoneView,PasswordResetConfirmView,PasswordResetCompleteView #LoginView,LogoutView,PasswordResetView,PasswordResetDoneView,PasswordResetConfirmView,PasswordResetCompleteView
app_name = 'online_books' app_name = 'online_books'
urlpatterns = [ urlpatterns = [
path('home/', views.home_view, name='home'),
# path('', LoginView.as_view(template_name='stud_app/login.html',authentication_form=StudentLoginForm), name="login"),
# url('login/', views.StudentView.as_view(), name="login"),
# path('', views.blank_page),
# path('login/', views.login_view, name="login"),
path('login/', login, name="login"),
path('logout/', LogoutView.as_view(template_name='online_books/logout.html'), name="logout"),
# path('<username>/home/', views.home_view, name="home"),
# path('<username>/courses/', views.courses_view, name="courses"),
# path('<username>/exams/', views.exam_list_view, name="exams"),
# path('<username>/exams/<int:exam_id>', views.exam_view, name="exams"),
# path('<username>/scores/', views.scores_view, name="scores"),
] ]
\ No newline at end of file
from django.urls import reverse_lazy
from django.views import generic
from django.contrib.auth.decorators import login_required
from django.shortcuts import render from django.shortcuts import render
# Create your views here. from .models import *
@login_required()
def home_view(request):
books = Book.objects.all()
return render(request, 'home.html', context={
'books' : books,
})
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{% block title %}BOOK SITE{% endblock %}</title>
</head>
<body>
<main>
<h1>BOOK SITE</h1>
{% block content %}
{% endblock %}
</main>
</body>
</html>
\ No newline at end of file
{% extends "base.html" %}
{% block content %}
<h1>Book List</h1>
{% if books %}
<ul>
{% for book in books %}
<li>{{book.book_title}}</li>
<li>{{book.author_fk.author_name}}</li>
<li>
{% for genre in book.genres.all %}
{{genre}},
{% endfor %}
</li>
{% if book.description %}
<li>{{book.description}}</li>
{% endif %}
<li>{{book.price}}</li>
<hr>
{% endfor %}
</ul>
{% else %}
<p>No book info</p>
{% endif %}
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}Log In{% endblock %}
{% block content %}
<h2>Log In</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Log In</button>
</form>
{% endblock %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment