logo

Design, Development and Testing of a Website for Fitzroy Catholic Bookshop

   

Added on  2023-06-12

15 Pages4680 Words337 Views
NAME
COURSE
UNIVERSITY/AFFILIATION
Design, Development and Testing of a Website for Fitzroy Catholic Bookshop_1
Introduction
The aim of this task is to create design, develop and test a website for the Fitzroy Catholic Bookshop.
The user can search for specific items based on the publisher, title, category, and price range. The web
project has been designed using xhtml thus making it compatible with almost all broswers regardless of
the platform or device. CSS and bootstrap have been used for styling and conditional styling while
python/django has been used to cater for server side requirement.
Additional Information.
The images used in the web project have been downloaded from www.userlogos.org (e.g
http://www.userlogos.org/files/logos/euphonicnight/Lib1.png) and usage of the images has been
acknowledged wherever they have been used. Images of my own were also uploaded to
https://image.ibb.co/, thus the <img> tags reference to that site in most cases.
“Fitzroy Catholic Bookshop” has been used as the company title through out the website.
So as to know the currently active page, the following peace of code has be used.
<meta charset="utf-8"> {% if title %}
<!-- if the var title has not null, append the (Current page) title to out Main Title -->
<title>Fitzroy Catholic Bookshop | {{title}}</title>
{% else %}
<title> Fitzroy Catholic Bookshop </title>
When the one browses to a page lets say the search results page, a “Home | Search Results” will be
displayed on top right side of that page.
The Look and Feal has been kept quite simple with the main content area background and Pale yellow
background for footers.
The functionality of the website has been tested and works as expected. A test script (tests.py) has been
includes. It contains dummy data and aims to assert that the results are as expected given predetermine
queries depicting real user actions.
Design, Development and Testing of a Website for Fitzroy Catholic Bookshop_2
Python Code.
admin.py
from django.contrib import admin
from .models import Image,Product
#Register the models.
admin.site.register(Image)
admin.site.register(Product)
forms.py
from django import forms
from . models import Product
CATEGORY_CHOICES= [
('book', 'Book'),
('audio book', 'Audio Books'),
('video', 'Video'),
('music', 'Music'),
]
PUBLISHER_CHOICES= [
('franciscan media', 'Franciscan Media'),
('Penguins', 'Penguins'),
('st pauls publication', 'St Pauls Publication'),
('marvels', 'Marvels'),
('harper collins', 'Harper Collins'),
]
class ProductForm(forms.Form):
'''
New Products form
'''
title = forms.CharField(label='Title',max_length = 140)
isbn = forms.CharField(label='ISBN',max_length = 64)
category = forms.CharField(label='Category', widget=forms.Select(choices=CATEGORY_CHOICES))
author = forms.CharField(label='Author',max_length = 64)
publisher = forms.CharField(label='Publisher', widget=forms.Select(choices=PUBLISHER_CHOICES))
price = forms.IntegerField(label='price')
quantity = forms.CharField(label='Quantity',max_length = 64)
image = forms.ImageField(label='Image',max_length = 64)
class SearchForm(forms.Form):
'''
Create the search form
'''
min_price = forms.IntegerField(label='Min price')
max_price = forms.IntegerField(label='Max price')
category = forms.CharField(label='Category', widget=forms.Select(choices=CATEGORY_CHOICES))
publisher = forms.CharField(label='Publisher', widget=forms.Select(choices=PUBLISHER_CHOICES))
Design, Development and Testing of a Website for Fitzroy Catholic Bookshop_3
apps.py
from django.apps import AppConfig
#Name of the Web Application
class FitzroybookshopConfig(AppConfig):
name = 'fitzroybookshop'
models.py
from django.db import models
class Product(models.Model):
'''
Products object
'''
title = models.CharField(max_length=140)
isbn = models.CharField(max_length=64)
category = models.CharField(max_length=64)
author = models.CharField(max_length=64)
publisher = models.CharField(max_length=64)
price = models.IntegerField( null = True)
quantity = models.IntegerField(null = True)
image = models.ImageField(upload_to = 'images/' ,null = True)
def __str__(self):
return self.title
def save_prod(self):
self.save()
def delete_prod(self):
self.delete()
@classmethod
def find_prod(cls,name):
found_prods = cls.objects.filter(username__icontains = name).all()
return found_prods
@classmethod
def search_prod(cls,min_price,max_price,category,publisher):
'''
return a list of objects which satisfy user query
'''
list_out =[]
requested_products = cls.objects.filter(category = category,publisher = publisher).all()
for item in requested_products:
if item.price>= min_price and item.price <= max_price:
list_out.append(item)
return list_out
class Image(models.Model):
'''
image objects
'''
name = models.CharField(max_length= 30)
image = models.ImageField(upload_to = 'images/' ,null = True)
Design, Development and Testing of a Website for Fitzroy Catholic Bookshop_4

End of preview

Want to access all the pages? Upload your documents or become a member.