Skip to content

Commit

Permalink
Misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PleatherStarfish committed Jul 6, 2024
1 parent b2000ee commit e64d325
Show file tree
Hide file tree
Showing 16 changed files with 140 additions and 126 deletions.
24 changes: 13 additions & 11 deletions backend/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,25 @@ def __str__(self):
@property
def is_premium(self):
"""
Checks if the user is currently premium.
Checks if the user is currently premium. Set to true for all users currently.
"""
if self.premium_admin_override:
return True
return True

now = timezone.now().date()
# if self.premium_admin_override:
# return True

if self.premium_until and self.premium_until >= now:
return True
# now = timezone.now().date()

if self.premium_until_via_kofi and self.premium_until_via_kofi >= now:
return True
# if self.premium_until and self.premium_until >= now:
# return True

if self.premium_until_via_patreon and self.premium_until_via_patreon >= now:
return True
# if self.premium_until_via_kofi and self.premium_until_via_kofi >= now:
# return True

return False
# if self.premium_until_via_patreon and self.premium_until_via_patreon >= now:
# return True

# return False

@property
def end_of_premium_display_date(self):
Expand Down
3 changes: 3 additions & 0 deletions backend/inventory/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def post(self, request, component_pk):
# Determine the editing mode from request
edit_mode = request.data.get("editMode", True)
location = request.data.get("location", "")

location_list = location.split(",") if location else None

# Filter the user inventory items by user, component_id, and location
Expand Down Expand Up @@ -64,6 +65,8 @@ def post(self, request, component_pk):

# If the user inventory item does not exist, create a new one
quantity = int(request.data.get("quantity", 0))
print("quantity", quantity)

component = Component.objects.get(id=component_pk)

user_inventory = UserInventory.objects.create(
Expand Down
Binary file added backend/static/images/kofi_button_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion backend/static/js/main.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions backend/templates/_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
<div id="banner" class="flex flex-col w-full gap-4 p-8 rounded-lg bg-[#d4e4ea]" role="alert">
<div class="flex flex-col w-full">
<span class="mb-6 text-5xl text-gray-500 font-display">Support the project</span>
<span class="text-gray-500">BOM Squad is an <a class="text-blue-500 hover:text-blue-700" href="https://github.com/PleatherStarfish/bomsquad">open-source</a> tool built and maintained by hobbyists. We rely on your support to keep us online. Become a Patreon subscriber and get access to premium features!</span>
<span class="text-gray-500">BOM Squad is an <a class="text-blue-500 hover:text-blue-700" href="https://github.com/PleatherStarfish/bomsquad">open-source</a> tool built and maintained by hobbyists. We rely on your support to keep us online. Subscriber on <a class="text-blue-500 hover:text-blue-700" href='https://ko-fi.com/bomsquad'>Ko-fi</a> and help choose the next module and feature we add!</span>
</div>
<div class="flex justify-end w-full gap-2 mt-2 sm:mt-0 sm:w-auto">
<button id="banner-hide-button" class="w-min flex items-center justify-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-slate-400 hover:bg-slate-500 sm:px-3 sm:py-1.5 sm:text-sm">
Hide
</button>
<a href="https://www.patreon.com/BOMSquad" target="_blank" rel="noopener noreferrer" class="w-min flex items-center justify-center px-4 py-2 border border-transparent rounded-md text-sm font-medium text-white bg-slate-700 hover:bg-slate-800 sm:px-3 sm:py-1.5 sm:text-sm ml-2 whitespace-nowrap">
<a href="https://ko-fi.com/bomsquad" target="_blank" rel="noopener noreferrer" class="w-min flex items-center justify-center px-4 py-2 border border-transparent rounded-md text-sm font-medium text-white bg-slate-700 hover:bg-slate-800 sm:px-3 sm:py-1.5 sm:text-sm ml-2 whitespace-nowrap">
Support BOM Squad
</a>
</div>
Expand Down
14 changes: 8 additions & 6 deletions backend/templates/components/dropdown_menu.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{% load static %}

<div class="flex items-center space-x-2">
<div class="border-r border-gray-100">
<a
href="{% url 'premium' %}"
class="text-white hover:text-gray-100 px-4 inline-flex items-center border rounded border-[#212529] transition-all duration-200"
>Support</a
>
<div class="pr-4 border-r border-gray-100">
<a href="https://ko-fi.com/bomsquad">
<img
width="150px"
src="{% static 'images/kofi_button_blue.png' %}"
alt="Support on Ko-fi"
/>
</a>
</div>
<button
class="block ml-4 text-white menu-button text-decoration-none focus:outline-none"
Expand Down
2 changes: 1 addition & 1 deletion backend/templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h5 class="m-0">
<h1 class="mb-1 font-semibold text-gray-900">Support</h1>
<ul class="text-sm text-gray-600 list-none">
<li>
<a href="/support" class="text-gray-400 hover:text-gray-700">Support</a>
<a href="https://ko-fi.com/bomsquad" class="text-gray-400 hover:text-gray-700">Support</a>
</li>
<li>
<a href="https://github.com/PleatherStarfish/bomsquad" class="text-gray-400 hover:text-gray-700">Contribute on GitHub</a>
Expand Down
14 changes: 8 additions & 6 deletions backend/templates/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@
{% include "components/dropdown_menu.html" with button_text=user.email dropdown_items=dropdown_items %}
{% else %}
<div class="flex items-center space-x-2">
<div class="border-r border-gray-100">
<a
href="{% url 'premium' %}"
class="text-white hover:text-gray-100 px-4 inline-flex items-center border rounded border-[#212529] transition-all duration-200"
>Support</a
>
<div class="pr-4 border-r border-gray-100">
<a href="https://ko-fi.com/bomsquad">
<img
width="150px"
src="{% static 'images/kofi_button_blue.png' %}"
alt="Support on Ko-fi"
/>
</a>
</div>
<a
href="{% url 'account_login' %}"
Expand Down
82 changes: 36 additions & 46 deletions backend/templates/pages/disclaimer.html
Original file line number Diff line number Diff line change
@@ -1,74 +1,64 @@
{% extends '_base.html' %}
{% block title %}About page{% endblock %}
{% block content %}
<h1 class='text-4xl py-6'>Liability Disclaimer for bom-squad.com</h1>
{% extends '_base.html' %} {% block title %}About page{% endblock %} {% block
content %}
<h1 class="py-6 text-4xl">Liability Disclaimer for bom-squad.com</h1>

<div class="flex flex-col space-y-4">
<p>
The Bom Squad website (hereinafter referred to as "the Website") provides
information about Eurorack modules, including bill of materials (BOM) and
other related information. However, Bom Squad (hereinafter referred to as "we"
or "us") cannot guarantee the accuracy, completeness, or reliability of the
information provided on the Website.
The Bom Squad website ("the Website") provides information about Eurorack
modules, including bill of materials (BOM) and related details. However, Bom
Squad ("we" or "us") cannot guarantee the accuracy, completeness, or
reliability of the information on the Website.
</p>

<p>
The information provided on the Website
is for general informational purposes only and should not be considered as
professional advice or relied upon for any specific purpose. Users of the
Website should exercise their own judgment and discretion when using the
information provided, and verify the accuracy of the BOM or other information
before relying on it for any purpose, including but not limited to building
Eurorack modules.
The information on the Website is for general informational purposes only
and should not be considered professional advice. Users should exercise
their own judgment and verify the accuracy of the BOM or other information
before relying on it for any purpose, including building Eurorack modules.
</p>

<p>
We do not assume any liability for any errors, omissions, or
inaccuracies in the BOM or other information provided on the Website. We shall
not be responsible for any loss, damage, injury, or inconvenience arising out
of or in connection with the use of the Website or reliance on the information
provided on the Website, including but not limited to any direct, indirect,
consequential, or incidental damages.
We do not assume any liability for errors, omissions, or inaccuracies in the
BOM or other information provided on the Website. We are not responsible for
any loss, damage, injury, or inconvenience arising from the use of the
Website or reliance on its information, including direct, indirect,
consequential, or incidental damages.
</p>

<p>
Users of the Website acknowledge and agree that they use the information provided
on the Website at their own risk, and that Bom Squad shall not be held responsible
for any consequences that may arise from the use or reliance on such information.
Users acknowledge that they use the Website at their own risk, and Bom Squad
is not responsible for any consequences from the use or reliance on its
information.
</p>

<p>
Furthermore, the Website may contain links to third-party websites or resources
that are not under our control. We do not endorse, warrant, or guarantee the
accuracy, reliability, or legality of any content, products, services, or
information provided on such third-party websites or resources. Users of the Website
acknowledge and agree that they access and use such third-party websites or resources
at their own risk, and that Bom Squad shall not be liable for any loss or damage
arising out of or in connection with the use of such third-party websites or
resources.
The Website may contain links to third-party websites or resources not under
our control. We do not endorse, warrant, or guarantee the accuracy,
reliability, or legality of any content, products, services, or information
on such third-party websites. Users acknowledge that they access and use
third-party websites or resources at their own risk, and Bom Squad is not
liable for any loss or damage arising from such use.
</p>

<p>
By using the Website, users acknowledge and agree to release,
indemnify, and hold harmless Bom Squad, its officers, employees, agents, and
affiliates from any and all claims, damages, liabilities, costs, and expenses
(including attorney's fees) arising out of or in connection with the use of
the Website or reliance on the information provided on the Website.
By using the Website, users agree to release, indemnify, and hold harmless
Bom Squad, its officers, employees, agents, and affiliates from any claims,
damages, liabilities, costs, and expenses (including attorney's fees)
arising from the use of the Website or reliance on its information.
</p>

<p>
This liability disclaimer shall be governed by and construed in accordance with the
laws of the jurisdiction where Bom Squad is based, without giving effect to
any principles of conflicts of law. Any disputes arising out of or in
connection with this liability disclaimer shall be subject to the exclusive
jurisdiction of the courts in the jurisdiction where Bom Squad is based.
This liability disclaimer is governed by the laws of the jurisdiction where
Bom Squad is based, without regard to conflict of law principles. Any
disputes arising from this liability disclaimer are subject to the exclusive
jurisdiction of the courts in the jurisdiction where Bom Squad is based.
</p>

<p>
By using the Website, users acknowledge that they have read, understood, and
agreed to this liability disclaimer in its entirety. If users do not agree
with any part of this liability disclaimer, they should refrain from using the
Website.
with any part of this liability disclaimer, they should refrain from using
the Website.
</p>
</div>
{% endblock content %}
70 changes: 46 additions & 24 deletions frontend/src/components/bom_list/addComponentModal.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Dialog, Transition } from "@headlessui/react";
import Quantity, { Types } from "./quantity";
import React, { useEffect, useState } from "react";
import React, { Fragment, useCallback, useEffect, useState } from "react";

import Accordion from "../../ui/Accordion";
import Button from "../../ui/Button";
import ForOurSubscribersModal from "../modals/ForOurSubscribersModal";
import { Fragment } from "react";
import LocationsTable from "./locationsTable";
import NumericInput from "react-numeric-input";
import SimpleEditableLocation from "../inventory/SimpleEditableLocation";
Expand All @@ -31,6 +30,7 @@ const AddComponentModal = ({
quantityRequired,
componentName,
}) => {
const [error, setError] = useState();
const [showForOurSubscribersModal, setShowForOurSubscribersModal] =
useState(false);
const [quantity, setQuantity] = useState();
Expand All @@ -41,7 +41,6 @@ const AddComponentModal = ({
const { user, userIsLoading, userIsError } = useAuthenticatedUser();

const addOrUpdateUserInventory = useAddOrUpdateUserInventory();

const addOrUpdateUserShoppingList = useAddOrUpdateUserShoppingList();
const addOrUpdateUserAnonymousShoppingList =
useAddOrUpdateUserAnonymousShoppingList();
Expand All @@ -60,36 +59,60 @@ const AddComponentModal = ({
const { data: locations } = useGetInventoryLocations(componentId);
const locationsData = locations ?? [];

const is_premium = user?.is_premium;
// const is_premium = user?.is_premium;

const handleSubmitQuantity = async () => {
const handleSubmitQuantity = useCallback(async () => {
try {
if (type === Types.INVENTORY) {
addOrUpdateUserInventory({
await addOrUpdateUserInventory.mutateAsync({
componentId,
quantity,
location: locationArray.join(","),
location: Array.isArray(locationArray) ? locationArray.join(",") : "",
editMode,
}, {
onSuccess: () => {
setOpen(false);
},
onError: (error) => {
console.error("Failed to update quantity", error);
setError("Failed to update quantity: ", error)
}
});
} else if (type === Types.SHOPPING) {
addOrUpdateUserShoppingList({
await addOrUpdateUserShoppingList.mutateAsync({
componentId,
...hookArgs,
quantity,
editMode,
}, {
onSuccess: () => {
setOpen(false);
},
onError: (error) => {
console.error("Failed to update quantity", error);
setError("Failed to update quantity: ", error)
}
});
} else if (type === Types.SHOPPING_ANON) {
addOrUpdateUserAnonymousShoppingList({
await addOrUpdateUserAnonymousShoppingList.mutateAsync({
componentId,
quantity,
editMode,
}, {
onSuccess: () => {
setOpen(false);
},
onError: (error) => {
console.error("Failed to update quantity", error);
setError("Failed to update quantity: ", error)
}
});
}
} catch (error) {
console.error("Failed to update quantity", error);
setError("Failed to update quantity: ", error)
}
setOpen(false);
};
});

useEffect(() => {
let newQuantity = parseInt(quantityRequired);
Expand Down Expand Up @@ -312,20 +335,18 @@ const AddComponentModal = ({
<Button
variant="primary"
onClick={() => {
if (type === Types.INVENTORY) {
handleSubmitQuantity();
}
handleSubmitQuantity();

if (
is_premium ||
user?.unique_module_ids.length < 3 ||
user?.unique_module_ids.includes(`${moduleId}`) ||
moduleId === null
) {
handleSubmitQuantity();
} else {
setShowForOurSubscribersModal(true);
}
// if (
// is_premium ||
// user?.unique_module_ids.length < 3 ||
// user?.unique_module_ids.includes(`${moduleId}`) ||
// moduleId === null
// ) {
// handleSubmitQuantity();
// } else {
// setShowForOurSubscribersModal(true);
// }
}}
>
{editMode ? "Update" : "Add"}
Expand All @@ -334,6 +355,7 @@ const AddComponentModal = ({
Cancel
</Button>
</div>
<div className="bg-red-500">{error}</div>
</Dialog.Panel>
</Transition.Child>
</div>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/saved_lists/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import Alert from "../../ui/Alert";
import BackButton from "../../ui/BackButton";
import Button from "../../ui/Button";
import { DateTime } from "luxon";
import ForOurSubscribersModal from "../modals/ForOurSubscribersModal";
import ListSlice from "../shopping_list/listSlice";
import Modal from "../../ui/Modal";
import goToSupport from "../../utils/goToSupport";
import useAddArchivedListToShoppingList from '../../services/useAddArchivedListToShoppingList';
import useAuthenticatedUser from "../../services/useAuthenticatedUser";
import useDeleteArchivedShoppingList from "../../services/useDeleteArchivedShoppingList";
import useGetArchivedShoppingLists from "../../services/useGetUserArchivedShoppingLists";
import { useNavigate } from 'react-router-dom';
import ForOurSubscribersModal from "../modals/ForOurSubscribersModal";
import goToSupport from "../../utils/goToSupport";

const SavedLists = () => {
const [deleteModalOpen, setDeleteModalOpen] = useState(false);
Expand Down Expand Up @@ -80,7 +80,7 @@ const SavedLists = () => {
<h1 className="mt-5 mb-12 text-3xl font-bold text-gray-700">
Saved Lists
</h1>
{sortedArchivedShoppingLists.length &&
{!!sortedArchivedShoppingLists.length &&
<div className="flex justify-end w-full">
<Button variant="secondary" onClick={toggleSortOrder} className="flex items-center">
{sortOrder === "desc" ? (
Expand Down
Loading

0 comments on commit e64d325

Please sign in to comment.