-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add biding model and improve listing model
- Loading branch information
1 parent
ad936f9
commit efd3375
Showing
18 changed files
with
155 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from django.contrib import admin | ||
|
||
from .models import User, Listing | ||
from .models import User, Listing, Biding | ||
|
||
admin.site.register(User) | ||
admin.site.register(Listing) | ||
admin.site.register(Biding) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 4.1.5 on 2023-01-31 19:29 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('auctions', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Biding', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('value', models.FloatField()), | ||
('buyer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bidings', to=settings.AUTH_USER_MODEL)), | ||
('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='bidings', to='auctions.listing')), | ||
], | ||
), | ||
] |
23 changes: 23 additions & 0 deletions
23
auctions/migrations/0003_listing_photo_alter_biding_value.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 4.1.5 on 2023-01-31 19:37 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('auctions', '0002_biding'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='listing', | ||
name='photo', | ||
field=models.ImageField(blank=True, upload_to='photos/'), | ||
), | ||
migrations.AlterField( | ||
model_name='biding', | ||
name='value', | ||
field=models.DecimalField(decimal_places=2, max_digits=6), | ||
), | ||
] |
37 changes: 37 additions & 0 deletions
37
auctions/migrations/0004_rename_name_listing_title_remove_listing_photo_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Generated by Django 4.1.5 on 2023-01-31 19:56 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('auctions', '0003_listing_photo_alter_biding_value'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='listing', | ||
old_name='name', | ||
new_name='title', | ||
), | ||
migrations.RemoveField( | ||
model_name='listing', | ||
name='photo', | ||
), | ||
migrations.AddField( | ||
model_name='listing', | ||
name='category', | ||
field=models.CharField(blank=True, choices=[('Fashion', 'Fashion'), ('Home', 'Home'), ('Electronics', 'Electronics'), ('Toys', 'Toys'), ('Other', 'Other')], max_length=24), | ||
), | ||
migrations.AddField( | ||
model_name='listing', | ||
name='initial_bid', | ||
field=models.DecimalField(decimal_places=2, default=0.0, max_digits=6), | ||
), | ||
migrations.AddField( | ||
model_name='listing', | ||
name='photo_url', | ||
field=models.URLField(blank=True), | ||
), | ||
] |
Binary file not shown.
Binary file added
BIN
+1.03 KB
auctions/migrations/__pycache__/0003_listing_photo_alter_biding_value.cpython-311.pyc
Binary file not shown.
Binary file added
BIN
+1.56 KB
.../__pycache__/0004_rename_name_listing_title_remove_listing_photo_and_more.cpython-311.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% extends "auctions/layout.html" %} | ||
|
||
{% block body %} | ||
<h2>{{ listing.title }}</h2> | ||
<img src="{{ listing.photo_url }}" width="256"> | ||
<ul> | ||
<li>Description: {{ listing.description }}</li> | ||
<li>Seller: {{ listing.seller }}</li> | ||
{% if listing.category %} | ||
<li>Category: {{ listing.category }}</li> | ||
{% endif %} | ||
</ul> | ||
|
||
<h2>Bidings</h2> | ||
<ul> | ||
{% for bid in bidings %} | ||
<li>{{ bid }}</li> | ||
{% empty %} | ||
<li>Minimal bid: {{ listing.initial_bid }}</li> | ||
{% endfor %} | ||
</ul> | ||
|
||
<a href="{% url 'index' %}">All Listings</a> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.