Created new models for user and userfavorites.

Made migrations.
Added a tempprofile html file and edited profile so it can access the pk of the user.
Modified urls and views accordingly.
Co-authored-by: 's avatarpinkboheme <pinkboheme@users.noreply.github.com>
parent 400f5100
...@@ -9,12 +9,15 @@ ...@@ -9,12 +9,15 @@
{% block content %} {% block content %}
<div class="profile-container"> <div class="profile-container">
<div class="username-section profile-element"> <div class="username-section displayname profile-element">
<h2>This is user's profile</h2> <h2>This is {{ displayname }}'s profile</h2>
</div> </div>
<div class-"user-img profile-element"> <div class-"user-img userimage profile-element">
<img src="https://minimaltoolkit.com/images/randomdata/female/64.jpg" alt="profile-image"> <img src="https://minimaltoolkit.com/images/randomdata/female/64.jpg" alt="profile-image">
</div> </div>
<div class "username profile-element">
<h4> {{ username }} </h4>
</div>
<div class="btn-group profile-element" role="group" aria-label="Basic example"> <div class="btn-group profile-element" role="group" aria-label="Basic example">
<button type="button" class="btn btn-primary">My Store</button> <button type="button" class="btn btn-primary">My Store</button>
<button type="button" class="btn btn-primary">Edit Profile</button> <button type="button" class="btn btn-primary">Edit Profile</button>
......
{% 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' current_user.userid %}">{{ current_user.userid}}</a></h1>
{% endblock %}
\ No newline at end of file
# Generated by Django 4.0.3 on 2022-04-05 08:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0002_auctionbid_authgroup_authgrouppermissions_and_more'),
]
operations = [
migrations.CreateModel(
name='Boodleuser',
fields=[
('userid', models.AutoField(primary_key=True, serialize=False)),
('displayname', models.CharField(max_length=255)),
('pword', models.CharField(max_length=255)),
('username', models.CharField(max_length=255)),
],
options={
'db_table': 'boodleuser',
'managed': False,
},
),
migrations.CreateModel(
name='Store',
fields=[
('storeid', models.AutoField(primary_key=True, serialize=False)),
('storename', models.CharField(max_length=255)),
('storedesc', models.CharField(max_length=700)),
],
options={
'db_table': 'store',
'managed': False,
},
),
migrations.CreateModel(
name='Userfavorites',
fields=[
('favoriteid', models.AutoField(primary_key=True, serialize=False)),
],
options={
'db_table': 'userfavorites',
'managed': False,
},
),
]
...@@ -31,9 +31,6 @@ class AuctionBid(models.Model): ...@@ -31,9 +31,6 @@ class AuctionBid(models.Model):
managed = False managed = False
db_table = 'auctionbid' db_table = 'auctionbid'
def __str__(self):
return '%d' % (self.amount)
class AuthGroup(models.Model): class AuthGroup(models.Model):
name = models.CharField(unique=True, max_length=150) name = models.CharField(unique=True, max_length=150)
...@@ -101,6 +98,17 @@ class AuthUserUserPermissions(models.Model): ...@@ -101,6 +98,17 @@ 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'
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)
...@@ -166,3 +174,13 @@ class Store(models.Model): ...@@ -166,3 +174,13 @@ class Store(models.Model):
class Meta: class Meta:
managed = False managed = False
db_table = 'store' db_table = 'store'
class UserFavorites(models.Model):
favoriteid = models.AutoField(primary_key=True)
userid = models.ForeignKey(BoodleUser, models.DO_NOTHING, db_column='userid')
auctionid = models.ForeignKey(Auction, models.DO_NOTHING, db_column='auctionid')
class Meta:
managed = False
db_table = 'userfavorites'
...@@ -7,10 +7,12 @@ urlpatterns = [ ...@@ -7,10 +7,12 @@ 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'), 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'),
path('startauction', startAuction, name='startauction'), path('startauction', startAuction, name='startauction'),
path('profile', profile, name='profile') # this is tempuser profile
path('profile', tempProfile, name='profile'),
path('profile/<int:pk>', profile, name='profileid'),
] ]
\ No newline at end of file
...@@ -100,7 +100,6 @@ def mystore(request, pk): ...@@ -100,7 +100,6 @@ def mystore(request, pk):
context = { context = {
'current_store':current_store, 'current_store':current_store,
'store_items':store_items 'store_items':store_items
} }
return render(request, "boodlesite/templates/store.html", context) return render(request, "boodlesite/templates/store.html", context)
...@@ -137,7 +136,26 @@ def startAuction(request): ...@@ -137,7 +136,26 @@ def startAuction(request):
return render(request, "boodlesite/templates/startauction.html", context) return render(request, "boodlesite/templates/startauction.html", context)
def profile(request): def tempProfile(request): # temp view
#### Access to store 1 [ edit accordingly when it becomes accessible thru a user ] ####
current_user =BoodleUser.objects.get(userid=1)
context = {
'current_user':current_user #### used for navbar, access to user1
}
return render(request, "boodlesite/templates/tempprofile.html", context)
def profile(request, pk):
# filter the favorites i think from auction tapos # filter the favorites i think from auction tapos
# we need to add things like .add() and .remove() # we need to add things like .add() and .remove()
return render(request, "boodlesite/templates/profile.html") # get the user's information
current_user = BoodleUser.objects.get(pk=pk)
context = {
'displayname': current_user.displayname,
'username':current_user.username,
}
return render(request, "boodlesite/templates/profile.html", context)
\ No newline at end of file
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