diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07129c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +media/ diff --git a/.vscode/settings.json b/.vscode/settings.json index fafb871..fe800d2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "python.pythonPath": "C:\\ProgramData\\Anaconda3\\python.exe" + "python.pythonPath": "C:\\Python39\\python.exe" } \ No newline at end of file diff --git a/auctions/__pycache__/__init__.cpython-37.pyc b/auctions/__pycache__/__init__.cpython-37.pyc index 7342046..8da1c50 100644 Binary files a/auctions/__pycache__/__init__.cpython-37.pyc and b/auctions/__pycache__/__init__.cpython-37.pyc differ diff --git a/auctions/__pycache__/admin.cpython-37.pyc b/auctions/__pycache__/admin.cpython-37.pyc index bdfb581..1dbd49a 100644 Binary files a/auctions/__pycache__/admin.cpython-37.pyc and b/auctions/__pycache__/admin.cpython-37.pyc differ diff --git a/auctions/__pycache__/forms.cpython-37.pyc b/auctions/__pycache__/forms.cpython-37.pyc new file mode 100644 index 0000000..48221db Binary files /dev/null and b/auctions/__pycache__/forms.cpython-37.pyc differ diff --git a/auctions/__pycache__/forms.cpython-39.pyc b/auctions/__pycache__/forms.cpython-39.pyc index ff6697c..4fe2dcf 100644 Binary files a/auctions/__pycache__/forms.cpython-39.pyc and b/auctions/__pycache__/forms.cpython-39.pyc differ diff --git a/auctions/__pycache__/models.cpython-37.pyc b/auctions/__pycache__/models.cpython-37.pyc index d3d8c8d..1f785b8 100644 Binary files a/auctions/__pycache__/models.cpython-37.pyc and b/auctions/__pycache__/models.cpython-37.pyc differ diff --git a/auctions/__pycache__/models.cpython-39.pyc b/auctions/__pycache__/models.cpython-39.pyc index 209a5ed..5e95a8a 100644 Binary files a/auctions/__pycache__/models.cpython-39.pyc and b/auctions/__pycache__/models.cpython-39.pyc differ diff --git a/auctions/__pycache__/urls.cpython-37.pyc b/auctions/__pycache__/urls.cpython-37.pyc index 4eb3204..2ea67bf 100644 Binary files a/auctions/__pycache__/urls.cpython-37.pyc and b/auctions/__pycache__/urls.cpython-37.pyc differ diff --git a/auctions/__pycache__/views.cpython-37.pyc b/auctions/__pycache__/views.cpython-37.pyc index 13fd5fd..0152083 100644 Binary files a/auctions/__pycache__/views.cpython-37.pyc and b/auctions/__pycache__/views.cpython-37.pyc differ diff --git a/auctions/__pycache__/views.cpython-39.pyc b/auctions/__pycache__/views.cpython-39.pyc index 04032c7..10b82a8 100644 Binary files a/auctions/__pycache__/views.cpython-39.pyc and b/auctions/__pycache__/views.cpython-39.pyc differ diff --git a/auctions/forms.py b/auctions/forms.py index 5c754c4..61168a7 100644 --- a/auctions/forms.py +++ b/auctions/forms.py @@ -25,11 +25,11 @@ class BidForm(forms.Form): bid = forms.DecimalField(decimal_places=2) class CreateForm(forms.Form): - title = forms.CharField( max_length=100, widget=forms.TextInput(attrs={'placeholder': 'title'})) - desc= forms.CharField(max_length=100,widget=forms.TextInput(attrs={'placeholder': 'description'})) - starting_bid= forms.IntegerField(widget=forms.TextInput(attrs={'placeholder': 'Starting bid'})) - category = forms.ChoiceField(choices=categories) - photo = forms.ImageField() + title = forms.CharField( max_length=100, widget=forms.TextInput(attrs={'placeholder': 'title'}),required=True) + desc= forms.CharField(max_length=100,widget=forms.TextInput(attrs={'placeholder': 'description'}),required=True) + starting_bid= forms.DecimalField(decimal_places=2,widget=forms.TextInput(attrs={'placeholder': 'Starting bid'}), required=True) + category = forms.ChoiceField(choices=categories,required=True) + photo = forms.ImageField(required=False) def __init__(self, *args, **kwargs): super(CreateForm, self).__init__(*args, **kwargs) diff --git a/auctions/migrations/__pycache__/0001_initial.cpython-37.pyc b/auctions/migrations/__pycache__/0001_initial.cpython-37.pyc index 1fe3eb0..480ffb8 100644 Binary files a/auctions/migrations/__pycache__/0001_initial.cpython-37.pyc and b/auctions/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/auctions/migrations/__pycache__/0002_auctionlisting_closed.cpython-37.pyc b/auctions/migrations/__pycache__/0002_auctionlisting_closed.cpython-37.pyc index a78b398..2e55e14 100644 Binary files a/auctions/migrations/__pycache__/0002_auctionlisting_closed.cpython-37.pyc and b/auctions/migrations/__pycache__/0002_auctionlisting_closed.cpython-37.pyc differ diff --git a/auctions/migrations/__pycache__/__init__.cpython-37.pyc b/auctions/migrations/__pycache__/__init__.cpython-37.pyc index 72625fe..78f5809 100644 Binary files a/auctions/migrations/__pycache__/__init__.cpython-37.pyc and b/auctions/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/auctions/models.py b/auctions/models.py index 3c1d710..3ce29b2 100644 --- a/auctions/models.py +++ b/auctions/models.py @@ -20,7 +20,7 @@ class AuctionListing(models.Model): user = models.ForeignKey(User,on_delete = models.CASCADE) price = models.DecimalField(max_digits = 10,decimal_places = 2) desc = models.CharField(max_length = 1000) - picture = models.ImageField(); + picture = models.ImageField(default='default.png'); category = models.CharField(max_length = 64,choices=category_choices) date_added = models.DateTimeField(auto_now_add=True) closed = models.BooleanField(default=False) diff --git a/auctions/templates/auctions/all_listings.html b/auctions/templates/auctions/all_listings.html index ba65f56..4f7c714 100644 --- a/auctions/templates/auctions/all_listings.html +++ b/auctions/templates/auctions/all_listings.html @@ -9,7 +9,7 @@
- Preview not found + Preview not found
diff --git a/auctions/templates/auctions/category.html b/auctions/templates/auctions/category.html index c8e873f..9a155f8 100644 --- a/auctions/templates/auctions/category.html +++ b/auctions/templates/auctions/category.html @@ -10,7 +10,7 @@
- Preview not found + Preview not found
diff --git a/auctions/templates/auctions/index.html b/auctions/templates/auctions/index.html index 5ec72b1..3265d9d 100644 --- a/auctions/templates/auctions/index.html +++ b/auctions/templates/auctions/index.html @@ -10,7 +10,7 @@
- Preview not found + Preview not found
diff --git a/auctions/templates/auctions/listing.html b/auctions/templates/auctions/listing.html index 77b02b0..69ca781 100644 --- a/auctions/templates/auctions/listing.html +++ b/auctions/templates/auctions/listing.html @@ -37,7 +37,7 @@ {% if user.is_authenticated and user != Listing.user %}
{% csrf_token %} - {{ bid_form }} + {{ bid_form.as_p }}
diff --git a/auctions/views.py b/auctions/views.py index 8ddbe45..54415d2 100644 --- a/auctions/views.py +++ b/auctions/views.py @@ -7,9 +7,7 @@ from django import forms from .models import User,AuctionListing,Comment,Bids from .forms import BidForm,CreateForm - - - +categories=["Fashion","Electronics","Home","Sports","Toys","Automobile","Books","Videogames","Others"] def watch(request,title): """ @@ -165,7 +163,10 @@ def create(request): if request.method == 'POST': form = CreateForm(request.POST, request.FILES) if form.is_valid(): - listing_obj = AuctionListing(title = form.cleaned_data["title"], desc =form.cleaned_data["desc"], user = request.user,price = form.cleaned_data["starting_bid"], picture = form.cleaned_data["photo"],category= form.cleaned_data["category"]) + if not form.cleaned_data["photo"]: + listing_obj = AuctionListing(title = form.cleaned_data["title"], desc =form.cleaned_data["desc"], user = request.user,price = form.cleaned_data["starting_bid"],category= form.cleaned_data["category"]) + else: + listing_obj = AuctionListing(title = form.cleaned_data["title"], desc =form.cleaned_data["desc"], user = request.user,price = form.cleaned_data["starting_bid"], picture = form.cleaned_data["photo"],category= form.cleaned_data["category"]) listing_obj.save() bid_obj = Bids(bid_value = form.cleaned_data["starting_bid"], listing = listing_obj, user = request.user) bid_obj.save() diff --git a/commerce/__pycache__/azure_storage.cpython-39.pyc b/commerce/__pycache__/azure_storage.cpython-39.pyc new file mode 100644 index 0000000..48d3f99 Binary files /dev/null and b/commerce/__pycache__/azure_storage.cpython-39.pyc differ diff --git a/commerce/__pycache__/s3_storage.cpython-39.pyc b/commerce/__pycache__/s3_storage.cpython-39.pyc new file mode 100644 index 0000000..d13b6a4 Binary files /dev/null and b/commerce/__pycache__/s3_storage.cpython-39.pyc differ diff --git a/commerce/__pycache__/settings.cpython-37.pyc b/commerce/__pycache__/settings.cpython-37.pyc index 098eb34..c0cde0f 100644 Binary files a/commerce/__pycache__/settings.cpython-37.pyc and b/commerce/__pycache__/settings.cpython-37.pyc differ diff --git a/commerce/__pycache__/settings.cpython-39.pyc b/commerce/__pycache__/settings.cpython-39.pyc index 4948a24..4fc5705 100644 Binary files a/commerce/__pycache__/settings.cpython-39.pyc and b/commerce/__pycache__/settings.cpython-39.pyc differ diff --git a/commerce/__pycache__/urls.cpython-37.pyc b/commerce/__pycache__/urls.cpython-37.pyc index bb63353..507a6b9 100644 Binary files a/commerce/__pycache__/urls.cpython-37.pyc and b/commerce/__pycache__/urls.cpython-37.pyc differ diff --git a/commerce/__pycache__/urls.cpython-39.pyc b/commerce/__pycache__/urls.cpython-39.pyc index 18ba202..a3f6562 100644 Binary files a/commerce/__pycache__/urls.cpython-39.pyc and b/commerce/__pycache__/urls.cpython-39.pyc differ diff --git a/commerce/azure_storage.py b/commerce/azure_storage.py new file mode 100644 index 0000000..2b10d45 --- /dev/null +++ b/commerce/azure_storage.py @@ -0,0 +1,9 @@ + +from storages.backends.azure_storage import AzureStorage + +class AzureMediaStorage(AzureStorage): + account_name = 'auctionimages' # Must be replaced by your + account_key = '3W/fel22r8ExgQMDr8KOxxklp80/slPtAznb+G1Hkq0DWuX2bOIXnQMpgmU/BIJdIWnbDsgMr2SbC5l9qfJJ6g==' # Must be replaced by your + azure_container = 'media' + expiration_secs = None + diff --git a/commerce/s3_storage.py b/commerce/s3_storage.py deleted file mode 100644 index 4325cbf..0000000 --- a/commerce/s3_storage.py +++ /dev/null @@ -1,5 +0,0 @@ -from storages.backends.s3boto3 import S3Boto3Storage - -class MediaStorage(S3Boto3Storage): - location = 'media' - file_overwrite = False \ No newline at end of file diff --git a/commerce/settings.py b/commerce/settings.py index 7dcbf90..3f7f898 100644 --- a/commerce/settings.py +++ b/commerce/settings.py @@ -124,3 +124,9 @@ STATIC_URL = '/static/' MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') + +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, 'auctions/static'), +] + + diff --git a/commerce/urls.py b/commerce/urls.py index 0bdde9d..91d5a4b 100644 --- a/commerce/urls.py +++ b/commerce/urls.py @@ -24,4 +24,19 @@ urlpatterns = [ ] if settings.DEBUG: # new - urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + + + + # + # # alternate photo to display + # if photo_url == "": + # photo_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/1/15/No_image_available_600_x_450.svg/1280px-No_image_available_600_x_450.svg.png" + # category_value = request.POST["category"] + # listing_obj = AuctionListing(title = title, desc = desc, user = request.user,price = starting_bid, picture = photo_url,category=category_value) + # listing_obj.save() + # bid_obj = Bids(bid_value = starting_bid, listing = listing_obj, user = request.user) + # bid_obj.save() + # return render(request,"auctions/index.html",{ + # "Listings" : AuctionListing.objects.all() + # }) \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index c5c6ef9..742dc9a 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/media/Screenshot_2021-01-12_121010.png b/media/Screenshot_2021-01-12_121010.png deleted file mode 100644 index ffe0c71..0000000 Binary files a/media/Screenshot_2021-01-12_121010.png and /dev/null differ