From c1159dd31c84ff28d005bf81fac74d096549a1d5 Mon Sep 17 00:00:00 2001 From: alexwholland Date: Sun, 9 Apr 2023 10:05:07 -0700 Subject: [PATCH] Removed unused models code --- scraper/models.py | 9 +-------- scraper/views.py | 12 +----------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/scraper/models.py b/scraper/models.py index c1e6a1d..9ec13c0 100644 --- a/scraper/models.py +++ b/scraper/models.py @@ -1,13 +1,6 @@ from django.db import models -class Item(models.Model): - title = models.CharField(max_length=1000) - rating = models.DecimalField(max_digits=8, decimal_places=1) - url = models.CharField(max_length=1000) - image = models.CharField(max_length=1000) - - def __str__(self): - return self.title +# Create your models here. diff --git a/scraper/views.py b/scraper/views.py index 45782b8..0b7f39a 100644 --- a/scraper/views.py +++ b/scraper/views.py @@ -5,13 +5,11 @@ from .utils import * from .scraper_class import FacebookScraper import re import statistics -from .models import Item class Index(View): def get(self, request): form = MarketForm() - latest_items = Item.objects.all().order_by('-id')[:10] - context = {'form': form, 'latest_items': latest_items} + context = {'form': form} return render(request, 'scraper/index.html', context) def post(self, request): @@ -39,10 +37,7 @@ class Index(View): lower_bound, upper_bound, median = find_viable_product(title, ramp_down=0.0) price_rating = price_difference_rating(initial_price, median) average_rating = statistics.mean([sentiment_rating, price_rating]) - - # Create a new Item object average_rating = round(average_rating, 1) - item = Item.objects.create(image=listing_image[0], title=title, rating=average_rating, url=shortened_url) context = { 'shortened_url': shortened_url, @@ -64,8 +59,3 @@ class Index(View): } return render(request, 'scraper/result.html', context) - - else: - latest_items = Item.objects.all().order_by('-id')[:10] - context = {'form': form, 'latest_items': latest_items} - return render(request, 'scraper/index.html', context)