Removed unused models code

This commit is contained in:
alexwholland
2023-04-09 10:05:07 -07:00
parent 9f808e0971
commit c1159dd31c
2 changed files with 2 additions and 19 deletions

View File

@@ -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.

View File

@@ -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)