diff --git a/app/forms.py b/app/forms.py index 6197d7b..b85c80e 100644 --- a/app/forms.py +++ b/app/forms.py @@ -48,7 +48,6 @@ class CheckItem(FlaskForm): class DeleteItem(FlaskForm): index = HiddenField() - it_del_submit = SubmitField("Delete item") def parseHiddenIndex(field: HiddenField, array: list[Any]) -> int | None: diff --git a/app/scrapers.py b/app/scrapers.py index ca99499..34bda9d 100644 --- a/app/scrapers.py +++ b/app/scrapers.py @@ -80,7 +80,7 @@ class GenericScraper(ScraperLike): price = soup.select_one(self._priceQuery) image = soup.select_one(self._imageQuery) - if name is None or price is None or image is None: + if name is None or image is None: raise ScrapeError( f"Failed to scrape site. Invalid webpage or queries: N:{name},P:{price},I:{image}" ) @@ -88,7 +88,11 @@ class GenericScraper(ScraperLike): name = name.text.strip() image = image.get("src") try: - x = self.priceParser(price.text) + if price is None: + price = "0" + else: + price = price.text + x = self.priceParser(price) reg = search(r"([0-9]+)(?:(?:\.|,)([0-9]+))?", x) if not reg: raise ValueError diff --git a/app/templates/base.html b/app/templates/base.html index 83340ad..f3ac209 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -14,50 +14,54 @@ {% endblock head %} - + + {% block aboveNavbar %} + {% endblock aboveNavbar %} - {% block content %} - {% endblock content %} +
+ + + {% block content %} + {% endblock content %} +
diff --git a/app/templates/edit.html b/app/templates/edit.html index bef1766..1d877de 100644 --- a/app/templates/edit.html +++ b/app/templates/edit.html @@ -1,125 +1,263 @@ {% set cpath = url_for("edit", id=wishlist.editId) %} {% extends "base.html" %} - +{% block middleNav %} + +{% endblock middleNav %} +{% block middleNavPhone %} +
  • View wishlist
  • +{% endblock middleNavPhone %} +
  • View wishlist
  • {% block content %} -
    -

    Edit '{{wishlist.title}}'

    - Manage your wishlist details and items -
    -
    - {{ form_wl_editinfo.hidden_tag() }} - {{ form_wl_editinfo.title.label }} - {{ form_wl_editinfo.title(placeholder=wishlist.title) }} - - {{ form_wl_editinfo.description.label }} - {{ form_wl_editinfo.description(placeholder=wishlist.description) }} - - {{ form_wl_editinfo.wl_edit_submit() }} -
    -
    -

    Urls

    - +
    + {{ form_wl_reseturls.hidden_tag() }} {{ form_wl_reseturls.wl_reset_submit(class="btn btn-soft btn-warning") + }} +
    + +
    + +

    Add/Delete items

    + +
    + + +
    - + + + {% endblock content %} diff --git a/app/templates/index.html b/app/templates/index.html index 94d9808..52b9159 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -1 +1,74 @@ {% extends "base.html" %} + +{% block aboveNavbar %} + +
    +
    +
    +
    +

    Hello there

    +

    + Welcome to WishThat. The place to create and share wishlists online. +

    + +
    +
    +
    + +{% endblock aboveNavbar %} + +{% block content %} +
    +

    Why Use Wishthat?

    +
    +
    +
    +

    Avoid Duplicate Purchases

    +

    Our system helps you keep track of what has been purchased, ensuring that you don't buy the same item twice.

    +
    +
    +
    +
    +

    No Account Needed

    +

    Start creating wishlists immediately without the hassle of signing up or logging in.

    +
    +
    +
    +
    +

    Price and Image Scraping

    +

    We scrape websites for the latest prices and images, making sure you don't have to painstakingly create wish items manually!

    +
    +
    +
    +
    +

    Easy to Use

    +

    Our user-friendly interface allows you to create and manage your wishlists effortlessly.

    +
    +
    +
    +
    +

    Fully Open Source

    +

    Wishthat is fully open-source and FOSS, allowing anyone to check our security.

    +
    +
    +
    +
    +

    Mobile friendly design

    +

    The software has been designed with mobile friendlyness in mind. Meaning that your phone addicted friends may enjoy this site as well.

    +
    +
    +
    + + + + +
    + +{% endblock content %} diff --git a/app/templates/view.html b/app/templates/view.html index 432990b..cb0e3ba 100644 --- a/app/templates/view.html +++ b/app/templates/view.html @@ -1,50 +1,76 @@ {% extends "base.html" %} - {% block content %} +
    + +
    +

    {{wishlist.title}}

    +

    {{wishlist.description}}

    +
    -

    {{wishlist.title}}

    -{{wishlist.description}} +
    + {% for item in wishlist.items %} +
    +
    + {{ item.title }} +
    +
    +

    {{ item.title }}

    +

    {{ item.description }}

    +
    +
    {{ "€" ~ item.price if not item.bought }} +
    + + {{ form.csrf_token }} + {{ form.num(value=loop.index) }} +
    +
    +
    +
    + {% endfor %} +
    +
    -edit - - - -

    Are you sure you bought this product. You won't be able to undo this.

    -
    - - -
    + + +
    + + - {% endblock content %} diff --git a/app/views.py b/app/views.py index 0a81987..fabb07e 100644 --- a/app/views.py +++ b/app/views.py @@ -85,6 +85,7 @@ def edit(id: str): return redirect(url_for("edit", id=wishlist.editId)) elif form_it_new.validate_on_submit() and form_it_new.it_new_submit.data: + print("NEW") f = form_it_new price = f.price.data if f.price.data != None else 0 @@ -107,7 +108,7 @@ def edit(id: str): db.session.commit() return redirect(url_for("edit", id=id)) - elif form_it_delete.validate_on_submit() and form_it_delete.it_del_submit.data: + elif form_it_delete.validate_on_submit() and form_it_delete.index.data: index = parseHiddenIndex(form_it_delete.index, wishlist.items) if index == None: return abort(400) diff --git a/instance/application.db b/instance/application.db index d3dec65..b7835f8 100644 Binary files a/instance/application.db and b/instance/application.db differ