Commit 35673d3f authored by Christine Dela Rosa's avatar Christine Dela Rosa

Merge with branch 'mate_devbranch', Add help page, Fix StartAuctionForm and DeleteItemForm

parents da314e13 c7bafd11
...@@ -36,7 +36,7 @@ ALLOWED_HOSTS = [] ...@@ -36,7 +36,7 @@ ALLOWED_HOSTS = []
INSTALLED_APPS = [ INSTALLED_APPS = [
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth', # Login, logout
'django.contrib.contenttypes', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
...@@ -133,5 +133,4 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'boodlesite\media') ...@@ -133,5 +133,4 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'boodlesite\media')
STATICFILES_DIRS = [ STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'boodlesite\static'), os.path.join(BASE_DIR, 'boodlesite\static'),
] ]
\ No newline at end of file
...@@ -373,14 +373,6 @@ nav a { ...@@ -373,14 +373,6 @@ nav a {
align-items: center; align-items: center;
} }
/* item detail view / add, edit item */
.item-image-container,
.item-form-container {
border: 2px solid black;
padding: 1rem;
}
/* ?USER'S PROFILE */ /* ?USER'S PROFILE */
.profile-container { .profile-container {
display: flex; display: flex;
...@@ -392,4 +384,120 @@ nav a { ...@@ -392,4 +384,120 @@ nav a {
.profile-element { .profile-element {
margin-top: .5rem; margin-top: .5rem;
margin-bottom: .5rem; margin-bottom: .5rem;
}
/*===== EDIT PROFILE FORM =====*/
.edit-profile-container {
margin: 0 auto;
padding: 1rem;
}
.profile-form-container{
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 3rem;
}
/* About Page*/
.about__container {
margin: 0 auto;
width: 90%;
}
.about__header{
text-align: center;
}
.about__blockone, .about__blocktwo, .about__blockthree {
display: flex;
justify-content: center;
padding: 2rem;
}
.block-explanation{
width: 70%;
border-radius: 20px;
border: 5px black solid;
padding: 20px;
margin: 10px;
}
.block-image, .row, .col {
text-align: center;
padding: 1rem;
}
.form-space, .button-space{
display: flex;
justify-content: center;
padding: 3rem;
}
/* Add Item */
.additem-container{
text-align: center;
}
/* item detail view / add, edit item */
.item-form-container {
padding: 1rem;
margin: 0 auto;
}
.storeform-header {
text-align: center;
}
/* girl help */
.help-header{
background-color: #4c9ed0;
border-radius: 7px 7px 5px 0px;
padding: 10px;
color: #fff;
text-align: center;
font-family: Archivo;
font-size: 20px;
}
.help-container{
width: 500px;
}
.help-container{
width: 800px;
margin: 100px auto;
background: #fff;
border-radius: 7px;
box-shadow: 1px 2px 4px rgba(0,0,0,.3);
}
.help-perq{
padding: 0px 20px 20px;
}
::-webkit-details-marker{
float: right;
margin-top: 3px;
}
.help-perq details{
background: #f6f6f6;
padding: 10px 20px;
border-radius: 7px;
margin-top: 20px;
font-family: Archivo;
font-size: 18px;
letter-spacing: 1px;
cursor: pointer;
}
.help-perq details summary{
outline: none;
}
.help-text {
font-size: 15px;
} }
\ No newline at end of file
{% extends 'boodlesite\templates\base.html' %}
{% load static %}
{% block title %}Boodle Homepage{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<div class="about__header">
<h1>About Boodle</h1>
</div>
<div class="about__container">
<!-- overview -->
<div class="about__blockone">
<div class="block-image">
<img src="../static/media/block_one_pic.jpg">
</div>
<div class="block-explanation">
<h3>What is Boodle?</h3>
<p>
Boodle aims to provide an online bidding platform for online users. Its services are tailored specifically to bidding services to make communication and purchsing facilitation easier between buyers and sellers. For buyers, the common practice of "paunahan" is made easy for sellers can track which user bid on what and prevents issues such as scamming by correctly identifying the user with the highest bid.
</p>
</div>
</div>
<!-- About the product -->
<div class="about__blocktwo">
<div class="block-explanation">
<h3>Mission-Vision</h3>
<p>
Our mission has been to improve current bidding platforms and to provide a space for auctioneers and consumers to interact freely.
Boodle aims to provide sellers with the appropriate tools to auction items and aims to provide buyers a reliable platform for placing
bids on auctioned items.
</p>
</div>
<div class="block-image">
<img src="../static/media/block_two_pic.jpg">
</div>
</div>
<!-- About the makers -->
<div class="about__blockthree">
<div class="block-explanation">
<h3>Who are we?</h3>
<p> The developers are Computer Science students from Ateneo de Manila University. They consider themselves online shopaholics and so they
decided to create a platform for online auctions.
</p>
</div>
</div>
<div class="block-image">
<div class="row">
<div class="col">
<h6>Carmina Atienza</h6>
<img src="../static/media/profile_pics/didz.jpg">
</div>
<div class="col">
<h6>Christine Dela Rosa</h6>
<img src="../static/media/profile_pics/tin.jpg">
</div>
</div>
<div class="row">
<div class="col">
<h6>Martina Reyes</h6>
<img src="../static/media/profile_pics/mate.jpg">
</div>
<div class="col">
<h6>Felizia Tiburcio</h6>
<img src="../static/media/profile_pics/felizia.jpg">
</div>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
...@@ -9,32 +9,20 @@ ...@@ -9,32 +9,20 @@
{% block content %} {% block content %}
<div class="container"> <div class="additem-container">
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
<div class="row">
<div class="col-lg-7 col-md-6">ITEM IMAGE CONTAINER <form action="" method="POST">
<div class="item-image-container"></div> {% csrf_token %}
</div>
<div class=" col-lg-5 col-md-6">ITEM FORM CONTAINER
<div class="item-form-container"> <div class="item-form-container">
<form action="" method="POST"> {{ form.as_p }}
{% csrf_token %}
{{ form.as_p }}
</div> </div>
<button type="submit" name="Add Item"> Add Item </button> <div class="button-space">
</form> <button type="button" class="btn btn-danger"><a href= "{% url 'storeid' request.user.id %}">Cancel</a></button>
</div> <button type="submit" class="btn btn-dark" name="Add Item"> Add Item </button>
</div> </div>
</div> </form>
<!-- Form with fields:
[Item name]
[Item Description]
[Floor Price] -->
<!-- Image, if no image add image -->
</div>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
{% if auction_bids %} {% if auction_bids %}
{% for bid in auction_bids %} {% for bid in auction_bids %}
<li><img src="" alt=""> <li><img src="" alt="">
<p>{{bid.boodleuserid.displayname}} offered {{ bid.amount }}</p> <p>{{bid.userid.username}} offered {{ bid.amount }}</p>
<p> &nbsp | &nbsp </p> <p> &nbsp | &nbsp </p>
<p>{{bid.bidtime | timesince}} ago </p> <p>{{bid.bidtime | timesince}} ago </p>
......
...@@ -32,15 +32,14 @@ ...@@ -32,15 +32,14 @@
<body> <body>
<nav id="main"> <nav id="main">
<h1>Hello, {{request.user}}</h1>
<ul> <ul>
<li><a href="/">Home</a></li> <li><a href="/">Home</a></li>
<li><a href="#">About</a></li> <li><a href="{% url 'about' %}">About</a></li>
<li><a href="#">Help</a></li> <li><a href="{% url 'help' %}">Help</a></li>
<li><a href="/profile">My Profile</a></li> <li><a href="{% url 'profileid' request.user.id %}">My Profile</a></li>
<li><a href="/store">My Store</a></li> <li><a href="{% url 'logout' %}">Logout</a></li>
</ul> </ul>
</nav> </nav>
......
...@@ -9,32 +9,21 @@ ...@@ -9,32 +9,21 @@
{% block content %} {% block content %}
<div class="container"> <div class="edit-profile-container">
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
<div class="row"> <div class="">
<div class="col-lg-7 col-md-6">ITEM IMAGE CONTAINER <div class="profile-form-container">
<div class="item-image-container"></div> <form action="" method="POST">
</div> {% csrf_token %}
<div class=" col-lg-5 col-md-6">ITEM FORM CONTAINER {{ form.as_p }}
<div class="item-form-container"> <div class="button-space">
<form action="" method="POST"> <button type="button" class="btn btn-danger"><a href= "{% url 'profileid' request.user.id %}">Cancel</a></button>
{% csrf_token %} <button class="profile-submit-button btn btn-dark" type="submit" name="Add Item"> Save Changes </button>
{{ form.as_p }}
</div> </div>
<button type="submit" name="Add Item"> Save Changes </button>
</form> </form>
</div> </div>
</div> </div>
</div> </div>
<!-- Form with fields:
[Item name]
[Item Description]
[Floor Price] -->
<!-- Image, if no image add image -->
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'boodlesite\templates\base.html' %}
{% load static %}
{% block title %}Profile{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<div class="help-container">
<p class="help-header">FAQ</p>
<div class="help-perq">
<details>
<summary>Placing a Bid</summary>
<ul class="help-text">
<li>To place a bid, go to the homepage to check all on-going auctions </li>
<li>Find the desired auction and click on the title to go to the auction title</li>
<li>At the auction, click on the "Place Bid" button near the latest bids</li>
<li>A pop-up will appear, enter the a desired bidding value in the input box
<br> *Please note: only bids higher than the current highest bid will go through</li>
<li>Once you place the desired bid, click submit and the bid should appear in latest bid</li>
</ul>
</details>
<details>
<summary>Creating a Store</summary>
<ul class="help-text">
<li>Access your profile by clicking the link "My Profile" on the nav bar </li>
<li>Once accessed, below your profile picture is the button "Create Store"</li>
<li>Click this button and a pop up will appear where you input the desired store information</li>
<li>Once you click "Submit", the button will change into a link to access your store</li>
</ul>
</details>
<details>
<summary>Inventory Management</summary>
<ul class="help-text">
<li>To access your store, click the "My Store" button on the profile page</li>
<li>At the store page, you can view the current items in your inventory </li>
<li>Each item has the option to edit and delete an item below the item name</li>
<li>To add an item, click the "Add Item" button at the bottom of the page</li>
<li>Once selected, you will be redirected to a page where you can input the necessary information for an item</li>
<li>Once filled, select "Add Item" button and the item should appear on your store page</li>
</ul>
</details>
<details>
<summary>Starting an Auction</summary>
<ul class="help-text">
<li>To access your store, click the "My Store" button on the profile page</li>
<li>To start an auction, select the "Start Auction" button at the bottom of the page
<br> *Note: You must have an existing item to start an auction and you cannot create duplicate auctions for a single item</li>
<li>Once selected, you will be redirected to a page where you can input the necessary information for the auction</li>
<li>Once filled, select "Start Auction" button and the auction should appear on the homepage</li>
</ul>
</details>
<details>
<summary>Profile Management</summary>
<ul class="help-text">
<li>Access your profile by clicking the link "My Profile" on the nav bar</li>
<li>Below the profile picture, there will be a button "Edit Profile"</li>
<li>Clicking this button, the you will be redirected to change your username</li>
<li>After filling it up and selecting "Save Changes". The changes will appear on the profile.</li>
</ul>
</details>
</div>
</div>
{% endblock %}
\ No newline at end of file
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<p>Boodle was founded by a group of four talented software engineers, who are currently Computer Science students <p>Boodle was founded by a group of four talented software engineers, who are currently Computer Science students
in Ateneo de Manila University. They believed they could change the status quo in Ateneo de Manila University. They believed they could change the status quo
of the e-commerce world—and with Boodle, they did. </p> of the e-commerce world—and with Boodle, they did. </p>
<button id="btn-read-more">Read more</button> <button id="btn-read-more"><a href="{% url 'about' %}">Read more</a></button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<!--If a user owns a store, they can access the store--> <!--If a user owns a store, they can access the store-->
{% if store %} {% if store %}
<button type="button" class="btn btn-primary"> <button type="button" class="btn btn-primary">
<a href= "{% url 'storeid' store %}" > <a href= "{% url 'storeid' store %}" style="color: white" >
My Store My Store
</a> </a>
</button> </button>
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
{% endif %} {% endif %}
<button type="button" class="btn btn-primary"> <button type="button" class="btn btn-primary">
<a href= "{% url 'editProfile' user %}" > <a href= "{% url 'editProfile' user %}" style="color: white" >
Edit Profile Edit Profile
</a></button> </a></button>
</div> </div>
...@@ -61,9 +61,8 @@ ...@@ -61,9 +61,8 @@
<!--Change auctions_now, auction to like favorites, favorite--> <!--Change auctions_now, auction to like favorites, favorite-->
<h2> Items {{displayname}} bid on </h2> <h2> Items {{displayname}} bid on </h2>
<div class="event-container"> <div class="event-container">
{% if auctionsOfUser %} {% if auctions_of_user %}
{% for id in idsOfAuction %} {% for id in ids_of_auction %}
{% if id.auctionend > currentdate %}
<div class="event"> <div class="event">
<img src="http://via.placeholder.com/640x360" alt=""> <img src="http://via.placeholder.com/640x360" alt="">
<div class="event-text"> <div class="event-text">
...@@ -73,7 +72,6 @@ ...@@ -73,7 +72,6 @@
<p>{{ id.auctionend }}</p> <p>{{ id.auctionend }}</p>
</div> </div>
</div> </div>
{% endif %}
{% endfor %} {% endfor %}
{% else %} {% else %}
......
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP" crossorigin="anonymous">
<style>
body,
html {
margin: 0;
padding: 0;
height: 100%;
background: #7abecc !important;
}
.user_card {
width: 350px;
margin-top: auto;
margin-bottom: auto;
background: #74cfbf;
position: relative;
display: flex;
justify-content: center;
flex-direction: column;
padding: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-moz-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-radius: 5px;
}
.form_container {
margin-top: 20px;
}
#form-title{
color: #fff;
}
.login_btn {
width: 100%;
background: #33ccff !important;
color: white !important;
}
.login_btn:focus {
box-shadow: none !important;
outline: 0px !important;
}
.login_container {
padding: 0 2rem;
}
.input-group-text {
background: #f7ba5b !important;
color: white !important;
border: 0 !important;
border-radius: 0.25rem 0 0 0.25rem !important;
}
.input_user,
.input_pass:focus {
box-shadow: none !important;
outline: 0px !important;
}
#messages{
background-color: grey;
color: #fff;
padding: 10px;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container h-100">
<div class="d-flex justify-content-center h-100">
<div class="user_card">
<div class="d-flex justify-content-center">
<h3 id="form-title">LOGIN</h3>
</div>
<div class="d-flex justify-content-center form_container">
<form method="POST" action="">
{% csrf_token %}
<div class="input-group mb-3">
<div class="input-group-append">
<span class="input-group-text"><i class="fas fa-user"></i></span>
</div>
<input type="text" name="username" placeholder="Username..." class="form-control">
</div>
<div class="input-group mb-2">
<div class="input-group-append">
<span class="input-group-text"><i class="fas fa-key"></i></span>
</div>
<input type="password" name="password" placeholder="Password..." class="form-control" >
</div>
<div class="d-flex justify-content-center mt-3 login_container">
<input class="btn login_btn" type="submit" value="Login">
</div>
</form>
</div>
{% for message in messages %}
<p id="messages">{{message}}</p>
{% endfor %}
<div class="mt-4">
<div class="d-flex justify-content-center links">
Don't have an account? <a href="{% url 'register' %}" class="ml-2">Sign Up</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" integrity="sha384-gfdkjb5BdAXd+lj+gudLWI+BXq4IuLW5IT+brZEZsLFm++aCMlF1V92rMkPaX4PP" crossorigin="anonymous">
<style>
body,
html {
margin: 0;
padding: 0;
height: 100%;
background: #7abecc !important;
}
.user_card {
width: 350px;
margin-top: auto;
margin-bottom: auto;
background: #74cfbf;
position: relative;
display: flex;
justify-content: center;
flex-direction: column;
padding: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-moz-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-radius: 5px;
}
.form_container {
margin-top: 20px;
}
#form-title{
color: #fff;
}
.login_btn {
width: 100%;
background: #33ccff !important;
color: white !important;
}
.login_btn:focus {
box-shadow: none !important;
outline: 0px !important;
}
.login_container {
padding: 0 2rem;
}
.input-group-text {
background: #f7ba5b !important;
color: white !important;
border: 0 !important;
border-radius: 0.25rem 0 0 0.25rem !important;
}
.input_user,
.input_pass:focus {
box-shadow: none !important;
outline: 0px !important;
}
</style>
</head>
<body>
<div class="container h-100">
<div class="d-flex justify-content-center h-100">
<div class="user_card">
<div class="d-flex justify-content-center">
<h3 id="form-title">REGISTER ACCOUNT</h3>
</div>
<div class="d-flex justify-content-center form_container">
<form method="POST" action="">
{% csrf_token %}
<div class="input-group mb-3">
<div class="input-group-append">
<span class="input-group-text"><i class="fas fa-user"></i></span>
</div>
<input type="text" name="username">
</div>
<div class="input-group mb-2">
<div class="input-group-append">
<span class="input-group-text"><i class="fas fa-envelope-square"></i></span>
</div>
<input type="email" name="email">
</div>
<div class="input-group mb-2">
<div class="input-group-append">
<span class="input-group-text"><i class="fas fa-key"></i></span>
</div>
<input type="password" name="password1">
</div>
<div class="input-group mb-2">
<div class="input-group-append">
<span class="input-group-text"><i class="fas fa-key"></i></span>
</div>
<input type="password" name="password2">
</div>
<div class="d-flex justify-content-center mt-3 login_container">
<input class="btn login_btn" type="submit" value="Register Account">
</div>
</form>
</div>
<div class="mt-4">
<div class="d-flex justify-content-center links">
Already have an account? <a href="{% url 'login' %}" class="ml-2">Login</a>
</div>
</div>
</div>
</div>
</div>
<script>
/* Because i didnt set placeholder values in forms.py they will be set here using vanilla Javascript
//We start indexing at one because CSRF_token is considered and input field
*/
//Query All input fields
var form_fields = document.getElementsByTagName('input')
form_fields[1].placeholder='Username..';
form_fields[2].placeholder='Email..';
form_fields[3].placeholder='Enter password...';
form_fields[4].placeholder='Re-enter Password...';
for (var field in form_fields){
form_fields[field].className += ' form-control'
}
</script>
</body>
</html>
...@@ -9,18 +9,25 @@ ...@@ -9,18 +9,25 @@
{% block content %} {% block content %}
<div class="container"> <div class="container">
<form action="" method="POST"> <form action="" method="POST">
{% csrf_token %} {% csrf_token %}
{{ form.as_p }} <div class="form-space">
{{ form.as_p }}
<button type="submit" name="savesauction">Start Auction</button> </div>
<div class="button-space">
<button type="button" class="btn btn-danger"><a href= "{% url 'storeid' request.user.id %}">Cancel</a></button>
<button type="submit" class="btn btn-dark" name="savesauction">Save Auction</button>
</div>
</form> </form>
</div> </div>
<input id="datetimepicker" type="text"> <input id="datetimepicker" type="text">
<script> <!-- <script>
$(function () { $(function () {
$("#id_auctionstart").datetimepicker(); $("#id_auctionstart").datetimepicker();
}); });
...@@ -28,7 +35,7 @@ ...@@ -28,7 +35,7 @@
$(function () { $(function () {
$("#id_auctionend").datetimepicker(); $("#id_auctionend").datetimepicker();
}); });
</script> </script> -->
<!-- Form fields: <!-- Form fields:
[Auction Title] [Auction Title]
......
...@@ -10,31 +10,19 @@ ...@@ -10,31 +10,19 @@
{% block content %} {% block content %}
<div class="container"> <div class="container">
<div class = "storeform-header">
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
<div class="row">
<div class="col-lg-7 col-md-6">ITEM IMAGE CONTAINER
<div class="item-image-container"></div>
</div>
<div class=" col-lg-5 col-md-6">ITEM FORM CONTAINER
<div class="item-form-container">
<form action="" method="POST">
{% csrf_token %}
{{ form.as_p }}
</div>
<button type="submit" name="Add Item"> Save Changes </button>
</form>
</div>
</div> </div>
<form action="" method="POST">
{% csrf_token %}
<div class="form-space">
{{ form.as_p }}
</div>
<div class="button-space">
<button type="button" class="btn btn-danger"><a href= "{% url 'storeid' request.user.id %}">Cancel</a></button>
<button type="submit" class="btn btn-dark" name="Add Item"> Save Changes </button>
</div>
</form>
</div> </div>
<!-- Form with fields:
[Item name]
[Item Description]
[Floor Price] -->
<!-- Image, if no image add image -->
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'boodlesite\templates\base.html' %}
{% load static %}
{% block title %}My Profile{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<h2>This is a temp page to access userid 1 (and not thru the navbar)</h2>
<p>Remove this page once nav bar is personalized that it
accesses the logged in user's profile</p>
<h1 text-align="center">Link to My Profile: <a href="{% url 'profileid' user_one.userid %}">{{ user_one.userid }}</a></h1>
<h1 text-align="center">Link to My OTHER Profile: <a href="{% url 'profileid' user_two.userid %}">{{user_two.userid}}</a></h1>
{% endblock %}
\ No newline at end of file
{% extends 'boodlesite\templates\base.html' %}
{% load static %}
{% block title %}My Store{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<h2>This is a temp page to access storeid 1 (and not thru the navbar)</h2>
<p>Remove this page once nav bar is personalized that it accesses the logged in user's store</p>
<h1 text-align="center">Link to My Store: <a href="{% url 'storeid' current_store.storeid %}">{{ current_store.storename }}</a></h1>
{% endblock %}
\ No newline at end of file
...@@ -12,15 +12,18 @@ import datetime, pytz ...@@ -12,15 +12,18 @@ import datetime, pytz
from django.contrib.admin.widgets import AdminSplitDateTime from django.contrib.admin.widgets import AdminSplitDateTime
from django.contrib.admin import widgets from django.contrib.admin import widgets
from django.contrib.auth.forms import UserCreationForm
from django import forms
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
class PlaceBidForm(forms.ModelForm): class PlaceBidForm(forms.ModelForm):
class Meta: class Meta:
model = AuctionBid model = AuctionBid
fields = ['amount', 'boodleuserid', 'auctionid'] fields = ['amount', 'userid', 'auctionid']
widgets = {'auctionid': forms.HiddenInput(), widgets = {'auctionid': forms.HiddenInput(),
'boodleuserid': forms.HiddenInput() 'userid': forms.HiddenInput()
} }
def clean(self): def clean(self):
...@@ -62,10 +65,8 @@ class StartAuctionForm(forms.ModelForm): ...@@ -62,10 +65,8 @@ class StartAuctionForm(forms.ModelForm):
# auctionstart = forms.SplitDateTimeField(widget=AdminSplitDateTime()) # auctionstart = forms.SplitDateTimeField(widget=AdminSplitDateTime())
# auctionend = forms.SplitDateTimeField(widget=AdminSplitDateTime()) # auctionend = forms.SplitDateTimeField(widget=AdminSplitDateTime())
# auctionstart = forms.DateTimeField(input_formats=['%d/%m/%Y %H:%M']) auctionstart = forms.DateTimeField(input_formats=['%d/%m/%Y %H:%M'])
# auctionend = forms.DateTimeField(input_formats=['%d/%m/%Y %H:%M']) auctionend = forms.DateTimeField(input_formats=['%d/%m/%Y %H:%M'])
class Meta: class Meta:
model = Auction model = Auction
...@@ -86,7 +87,6 @@ class StartAuctionForm(forms.ModelForm): ...@@ -86,7 +87,6 @@ class StartAuctionForm(forms.ModelForm):
end_time = self.cleaned_data.get('auctionend') end_time = self.cleaned_data.get('auctionend')
start_time = self.cleaned_data.get('auctionstart') start_time = self.cleaned_data.get('auctionstart')
current_date = timezone.now() current_date = timezone.now()
auctioned_item = self.cleaned_data['itemid'] auctioned_item = self.cleaned_data['itemid']
auctions = Auction.objects.all() auctions = Auction.objects.all()
...@@ -114,11 +114,15 @@ class CreateStoreForm(forms.ModelForm): ...@@ -114,11 +114,15 @@ class CreateStoreForm(forms.ModelForm):
class editBoodleUserForm(forms.ModelForm): class editBoodleUserForm(forms.ModelForm):
class Meta: class Meta:
model = BoodleUser model = AuthUser
fields = ['displayname', 'username', 'userid'] fields = ['username', 'id']
widgets = {'userid': forms.HiddenInput()} widgets = {'id': forms.HiddenInput()}
labels = { labels = {
'username': _('User Name'), 'username': _('User Name')
'displayname': _('Display Name') }
}
\ No newline at end of file class CreateUserForm(UserCreationForm):
class Meta:
model=User
fields=['username', 'email', 'password1', 'password2']
\ No newline at end of file
# Generated by Django 3.2.12 on 2022-05-18 09:48
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0004_delete_userfavorites'),
]
operations = [
migrations.DeleteModel(
name='Boodleuser',
),
]
...@@ -26,7 +26,7 @@ class AuctionBid(models.Model): ...@@ -26,7 +26,7 @@ class AuctionBid(models.Model):
amount = models.DecimalField(max_digits=15, decimal_places=4) amount = models.DecimalField(max_digits=15, decimal_places=4)
bidtime = models.DateTimeField(blank=True, null=True) bidtime = models.DateTimeField(blank=True, null=True)
auctionid = models.ForeignKey(Auction, models.DO_NOTHING, db_column='auctionid') auctionid = models.ForeignKey(Auction, models.DO_NOTHING, db_column='auctionid')
boodleuserid = models.ForeignKey('BoodleUser', models.DO_NOTHING, db_column='boodleuserid') userid = models.ForeignKey('AuthUser', models.DO_NOTHING, db_column='userid')
class Meta: class Meta:
managed = False managed = False
...@@ -99,20 +99,6 @@ class AuthUserUserPermissions(models.Model): ...@@ -99,20 +99,6 @@ class AuthUserUserPermissions(models.Model):
unique_together = (('user', 'permission'),) unique_together = (('user', 'permission'),)
class BoodleUser(models.Model):
userid = models.AutoField(primary_key=True)
displayname = models.CharField(max_length=255)
pword = models.CharField(max_length=255)
username = models.CharField(max_length=255)
class Meta:
managed = False
db_table = 'boodleuser'
def __str__(self):
return '%s' % (self.userid)
class DjangoAdminLog(models.Model): class DjangoAdminLog(models.Model):
action_time = models.DateTimeField() action_time = models.DateTimeField()
object_id = models.TextField(blank=True, null=True) object_id = models.TextField(blank=True, null=True)
...@@ -168,7 +154,7 @@ class Item(models.Model): ...@@ -168,7 +154,7 @@ class Item(models.Model):
class Meta: class Meta:
managed = False managed = False
db_table = 'item' db_table = 'item'
def __str__(self): def __str__(self):
return '%s' % (self.itemname) return '%s' % (self.itemname)
...@@ -178,11 +164,8 @@ class Store(models.Model): ...@@ -178,11 +164,8 @@ class Store(models.Model):
storeid = models.AutoField(primary_key=True) storeid = models.AutoField(primary_key=True)
storename = models.CharField(max_length=255) storename = models.CharField(max_length=255)
storedesc = models.CharField(max_length=700) storedesc = models.CharField(max_length=700)
userid = models.ForeignKey(BoodleUser, models.DO_NOTHING, db_column='userid', blank=True, null=True) userid = models.ForeignKey(AuthUser, models.DO_NOTHING, db_column='userid', blank=True, null=True)
class Meta: class Meta:
managed = False managed = False
db_table = 'store' db_table = 'store'
def __str__(self):
return '%s' % (self.storeid)
\ No newline at end of file
...@@ -8,7 +8,6 @@ urlpatterns = [ ...@@ -8,7 +8,6 @@ urlpatterns = [
path('auction', auction, name='auction'), path('auction', auction, name='auction'),
path('auction/<int:pk>/',auction, name='auctionid'), path('auction/<int:pk>/',auction, name='auctionid'),
path('error404', error404, name='error404'), path('error404', error404, name='error404'),
path('store', tempstore, name='store'), # this is tempstore
path('store/<int:pk>', mystore, name='storeid'), path('store/<int:pk>', mystore, name='storeid'),
path('additem', addItem, name='additem'), path('additem', addItem, name='additem'),
path('additem/<int:pk>', addItem, name='additemid'), path('additem/<int:pk>', addItem, name='additemid'),
...@@ -16,9 +15,12 @@ urlpatterns = [ ...@@ -16,9 +15,12 @@ urlpatterns = [
path('jsi18n', JavaScriptCatalog.as_view(), name='js-catlog'), path('jsi18n', JavaScriptCatalog.as_view(), name='js-catlog'),
path('startauction', startAuction, name='startauction'), path('startauction', startAuction, name='startauction'),
path('startauction/<int:pk>', startAuction, name='startauctionid'), path('startauction/<int:pk>', startAuction, name='startauctionid'),
# this is tempuser profile
path('profile', tempProfile, name='profile'),
path('profile/<int:pk>', profile, name='profileid'), path('profile/<int:pk>', profile, name='profileid'),
path('editstore/<int:pk>', editStore, name='editstoreid'), path('editstore/<int:pk>', editStore, name='editstoreid'),
path('editProfile/<int:pk>', editProfile, name='editProfile'), path('editProfile/<int:pk>', editProfile, name='editProfile'),
path('login', loginPage, name='login'),
path('register', registerPage, name='register'),
path('logout', logoutUser, name='logout'),
path('help', help, name='help'),
path('about', about, name='about')
] ]
\ No newline at end of file
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.http import HttpResponse from django.http import HttpResponse
from django.contrib.auth.forms import UserCreationForm
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils import timezone from django.contrib import messages
from django.contrib.auth import authenticate, login, logout
# restricting the views to logged in users, every view we want restricted
from django.contrib.auth.decorators import login_required
from .models import * from .models import *
from .forms import * from .forms import *
from datetime import datetime, timedelta from datetime import datetime, timedelta
def registerPage(request):
# dont want a logged in user to see this
if request.user.is_authenticated:
return redirect('/')
else:
form = CreateUserForm()
if request.method == 'POST':
form = CreateUserForm(request.POST)
if form.is_valid():
form.save()
user_name = form.cleaned_data.get('username')
password = form.cleaned_data.get('password1')
messages.success(request, 'Account was create for ' + user_name)
# boodleuser_inst = BoodleUser.objects.create(displayname=user_name, pword=password, username=user_name)
# boodleuser_inst.save()
return redirect('login')
context = {'form':form}
return render(request, 'boodlesite/templates/registration/register.html', context)
def loginPage(request):
# dont want a logged in user to see this
if request.user.is_authenticated:
return redirect('/')
else:
if request.method == 'POST':
user_name = request.POST.get('username')
pass_word = request.POST.get('password')
boodle_user = authenticate(request, username=user_name, password=pass_word)
if boodle_user is not None:
login(request, boodle_user)
return redirect('/')
else:
messages.info(request, 'Username OR Password is incorrect') # all msgs get sent here will be output
context = {}
return render(request, 'boodlesite/templates/registration/login.html', context)
def logoutUser(request):
logout(request)
return redirect('login')
@login_required(login_url='login')
def homepage(request): def homepage(request):
print(Auction.objects.all()) print(Auction.objects.all())
...@@ -32,6 +84,7 @@ def homepage(request): ...@@ -32,6 +84,7 @@ def homepage(request):
return render(request, "boodlesite/templates/index.html",context) return render(request, "boodlesite/templates/index.html",context)
@login_required(login_url='login')
def auction(request,pk): def auction(request,pk):
# Current auction ID # Current auction ID
...@@ -43,23 +96,24 @@ def auction(request,pk): ...@@ -43,23 +96,24 @@ def auction(request,pk):
highest_bid = auction_item.floorprice highest_bid = auction_item.floorprice
## ⭐ the user that is logged in ## ⭐ the user that is logged in
users = BoodleUser.objects.get(userid=3)
userid = users.userid users = AuthUser.objects.get(id=request.user.id)
userid = users.id
if auction_bids: if auction_bids:
highest_bid = auction_bids[0].amount highest_bid = auction_bids[0].amount
# PLACE BID FORM AND ADD TO FAVES FORM # PLACE BID FORM AND ADD TO FAVES FORM
form = PlaceBidForm(initial={'auctionid':auction, 'boodleuserid':users}) form = PlaceBidForm(initial={'auctionid':auction, 'userid':userid})
if request.method == 'POST': if request.method == 'POST':
form = PlaceBidForm(request.POST,initial={'auctionid':auction, 'boodleuserid':users}) form = PlaceBidForm(request.POST,initial={'auctionid':auction, 'userid':userid})
if form.is_valid(): if form.is_valid():
try: try:
amount = form.cleaned_data['amount'] amount = form.cleaned_data['amount']
# saves the bid by auctionid, amount, bidtime, boodleuserid # saves the bid by auctionid, amount, bidtime, boodleuserid
new_bid = AuctionBid( new_bid = AuctionBid(
amount=amount, bidtime=datetime.now(), amount=amount, bidtime=datetime.now(),
auctionid=auction, boodleuserid=users) auctionid=auction, userid=users)
new_bid.save() new_bid.save()
return redirect(f"/auction/{pk}") return redirect(f"/auction/{pk}")
except Exception as e: except Exception as e:
...@@ -73,7 +127,7 @@ def auction(request,pk): ...@@ -73,7 +127,7 @@ def auction(request,pk):
'highest_bid': highest_bid, 'highest_bid': highest_bid,
'auction_title': auction.title, 'auction_title': auction.title,
'auction_end': auction.auctionend, 'auction_end': auction.auctionend,
'user_profile': userid, 'user_profile': users,
'form' : form, 'form' : form,
} }
...@@ -84,20 +138,19 @@ def auction(request,pk): ...@@ -84,20 +138,19 @@ def auction(request,pk):
else: else:
return render(request, "boodlesite/templates/auction.html",context) return render(request, "boodlesite/templates/auction.html",context)
@login_required(login_url='login')
def error404(request): def error404(request):
return render(request, "boodlesite/templates/error404/notstarted_error404.html") return render(request, "boodlesite/templates/error404/notstarted_error404.html")
def tempstore(request): # temp view @login_required(login_url='login')
def about(request):
return render(request, "boodlesite/templates/about.html")
#### Access to store 1 [ edit accordingly when it becomes accessible thru a user ] #### @login_required(login_url='login')
current_store = Store.objects.get(storeid=1) def help(request):
return render(request, "boodlesite/templates/help.html")
context = {
'current_store':current_store #### used for navbar, access to store 1
}
return render(request, "boodlesite/templates/tempstore.html", context)
@login_required(login_url='login')
def mystore(request, pk): def mystore(request, pk):
#### Access to store 1 [ edit accordingly when it becomes accessible thru a user ] #### #### Access to store 1 [ edit accordingly when it becomes accessible thru a user ] ####
...@@ -106,6 +159,7 @@ def mystore(request, pk): ...@@ -106,6 +159,7 @@ def mystore(request, pk):
store_items = Item.objects.filter(storeid=pk) store_items = Item.objects.filter(storeid=pk)
all_auctions = Auction.objects.all() all_auctions = Auction.objects.all()
all_bids = AuctionBid.objects.all()
form = DeleteItemForm() form = DeleteItemForm()
...@@ -116,6 +170,11 @@ def mystore(request, pk): ...@@ -116,6 +170,11 @@ def mystore(request, pk):
current_item = Item.objects.get(itemid=item_id) current_item = Item.objects.get(itemid=item_id)
for auction in all_auctions: for auction in all_auctions:
if auction.itemid == current_item: if auction.itemid == current_item:
for bids in all_bids:
if bids.auctionid == auction:
AuctionBid.objects.filter(auctionid=auction.auctionid).delete()
Auction.objects.filter(itemid=item_id).delete() Auction.objects.filter(itemid=item_id).delete()
Item.objects.get(itemid=item_id).delete() Item.objects.get(itemid=item_id).delete()
...@@ -130,6 +189,7 @@ def mystore(request, pk): ...@@ -130,6 +189,7 @@ def mystore(request, pk):
return render(request, "boodlesite/templates/store.html", context) return render(request, "boodlesite/templates/store.html", context)
@login_required(login_url='login')
def addItem(request, pk): def addItem(request, pk):
# Current Store, pk here is the storeid # Current Store, pk here is the storeid
...@@ -151,6 +211,7 @@ def addItem(request, pk): ...@@ -151,6 +211,7 @@ def addItem(request, pk):
return render(request, "boodlesite/templates/additem.html", context) return render(request, "boodlesite/templates/additem.html", context)
@login_required(login_url='login')
def editItem(request, pk): def editItem(request, pk):
item = Item.objects.get(itemid=pk) item = Item.objects.get(itemid=pk)
...@@ -170,21 +231,23 @@ def editItem(request, pk): ...@@ -170,21 +231,23 @@ def editItem(request, pk):
return render(request, "boodlesite/templates/additem.html", context) return render(request, "boodlesite/templates/additem.html", context)
@login_required(login_url='login')
def startAuction(request, pk): def startAuction(request, pk):
# pk is store id # pk is store id
current_store = Store.objects.get(pk=pk) current_store = Store.objects.get(pk=pk)
store_id = current_store.storeid store_id = current_store.storeid
# get items under this store # get items under this store
store_items = Item.objects.filter(storeid=pk) store_items = Item.objects.filter(storeid=store_id)
# Current userid, change as per ⭐ whoever is logged in # Current userid, change as per ⭐ whoever is logged in
user = BoodleUser.objects.get(userid=3) user = AuthUser.objects.get(id=request.user.id)
userid = user.userid userid = user.id
# temp: all auctions # temp: all auctions
all_auctions = Auction.objects.all() all_auctions = Auction.objects.all()
form = StartAuctionForm(initial={'auctionstart':datetime.now()}) form = StartAuctionForm(initial={'auctionstart':datetime.now()})
form.fields["itemid"].queryset = store_items
if request.method == 'POST': if request.method == 'POST':
form = StartAuctionForm(request.POST) form = StartAuctionForm(request.POST)
...@@ -210,33 +273,21 @@ def startAuction(request, pk): ...@@ -210,33 +273,21 @@ def startAuction(request, pk):
return render(request, "boodlesite/templates/startauction.html", context) return render(request, "boodlesite/templates/startauction.html", context)
def tempProfile(request): # temp view @login_required(login_url='login')
#### Access to store 1 [ edit accordingly when it becomes accessible thru a user ] ####
user_one =BoodleUser.objects.get(userid=1) # shrek
user_two = BoodleUser.objects.get(userid=3) ## tony
context = {
'user_one':user_one, #### used for navbar, access to user1
'user_two':user_two, #### used for navbar, access to user1
}
return render(request, "boodlesite/templates/tempprofile.html", context)
def profile(request, pk): def profile(request, pk):
current_user = BoodleUser.objects.get(pk=pk) current_user = AuthUser.objects.get(pk=pk)
#auction bid user id = 3 --> bids user made --> know auctions g #auction bid user id = 3 --> bids user made --> know auctions g
## ⭐ the user that is logged in ## ⭐ the user that is logged in
bidsByUser = AuctionBid.objects.filter(boodleuserid=3).distinct('auctionid') bids_by_user = AuctionBid.objects.filter(userid=pk).distinct('auctionid')
auctionsOfUser = Auction.objects.all().distinct('auctionid') auctions_of_user = Auction.objects.all().distinct('auctionid')
idsOfAuction = [] ids_of_auction = []
for bid in bidsByUser: for bid in bids_by_user:
for auction in auctionsOfUser: for auction in auctions_of_user:
if bid.auctionid == auction: if bid.auctionid == auction:
idsOfAuction.append(bid.auctionid) ids_of_auction.append(bid.auctionid)
# print("These are the distinct auction IDs: ", idsOfAuction) # print("These are the distinct auction IDs: ", idsOfAuction)
...@@ -251,7 +302,7 @@ def profile(request, pk): ...@@ -251,7 +302,7 @@ def profile(request, pk):
won_itemids = [] won_itemids = []
won_auctions = [] won_auctions = []
for aucid in idsOfAuction: for aucid in ids_of_auction:
tempAuction = Auction.objects.get(pk=aucid.auctionid) tempAuction = Auction.objects.get(pk=aucid.auctionid)
auctionend = tempAuction.auctionend auctionend = tempAuction.auctionend
...@@ -270,14 +321,14 @@ def profile(request, pk): ...@@ -270,14 +321,14 @@ def profile(request, pk):
# 🔥Current Store, pk here is the storeid # 🔥Current Store, pk here is the storeid
current_user = BoodleUser.objects.get(pk=pk) current_user = AuthUser.objects.get(pk=pk)
form = CreateStoreForm(initial={'userid':pk}) form = CreateStoreForm(initial={'userid':pk})
current_store = Store.objects.filter(userid=current_user.userid) current_store = Store.objects.filter(userid=current_user.id)
current_storeid = None current_storeid = None
for i in current_store: for i in current_store:
current_storeid = i current_storeid = i.storeid
if request.method == 'POST': if request.method == 'POST':
form = CreateStoreForm(request.POST, initial={'userid':pk}) form = CreateStoreForm(request.POST, initial={'userid':pk})
...@@ -287,24 +338,21 @@ def profile(request, pk): ...@@ -287,24 +338,21 @@ def profile(request, pk):
return redirect('profileid', pk=pk) return redirect('profileid', pk=pk)
# 🔥 # 🔥
context = { context = {
'displayname': current_user.displayname, 'displayname': current_user.username,
'username': current_user.username, 'username': current_user.username,
'user': current_user.userid, 'user': current_user.id,
'store': current_storeid, 'store': current_storeid,
'bidsByUser' : bidsByUser, 'bidsByUser' : bids_by_user,
'auctionsOfUser': auctionsOfUser, 'auctions_of_user': auctions_of_user,
'auctions': auctions, 'auctions': auctions,
'idsOfAuction': idsOfAuction, 'ids_of_auction': ids_of_auction,
'won_items': won_itemids,
'won_auctions':won_auctions,
'currentdate':current_date,
'createStoreForm': form 'createStoreForm': form
} }
return render(request, "boodlesite/templates/profile.html", context) return render(request, "boodlesite/templates/profile.html", context)
@login_required(login_url='login')
def editStore(request, pk): def editStore(request, pk):
store= Store.objects.get(storeid=pk) store= Store.objects.get(storeid=pk)
...@@ -324,10 +372,11 @@ def editStore(request, pk): ...@@ -324,10 +372,11 @@ def editStore(request, pk):
return render(request, "boodlesite/templates/storeForm.html", context) return render(request, "boodlesite/templates/storeForm.html", context)
@login_required(login_url='login')
def editProfile(request, pk): def editProfile(request, pk):
user= BoodleUser.objects.get(userid=pk) # boodleuser object user= AuthUser.objects.get(id=pk) # authuser object
current_user = user.userid #boodle user id current_user = user.id # auth user id
form = editBoodleUserForm(instance=user) form = editBoodleUserForm(instance=user)
if request.method == 'POST': if request.method == 'POST':
......
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