Compare commits

3 Commits

Author SHA1 Message Date
eb1d1e1dd3 Fix Code Styling 2022-07-14 17:17:11 -07:00
21ffc736bc Add Pre-Commit Hooks 2022-07-14 17:12:35 -07:00
e6e7c20479 Add Docker Compose and Quick Start 2022-07-14 17:09:13 -07:00
10 changed files with 101 additions and 35 deletions

30
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,30 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/codespell-project/codespell
rev: v2.0.0
hooks:
- id: codespell
args:
- --ignore-words-list=sigl
- --skip="./.*,*.csv,*.json"
- --quiet-level=2
exclude_types: [csv, json]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings==1.5.0
- pydocstyle==5.1.1
files: ^(sigl|tests)/.+\.py$
- repo: https://github.com/PyCQA/isort
rev: 5.5.3
hooks:
- id: isort

View File

@@ -1,3 +1,22 @@
# Simple Grocery List (Sigl) # Simple Grocery List (Sigl)
Simple Grocery List, or **Sigl** (pronounced "sigil") is a lightweight shopping list manager designed for shared grocery lists (or any other shopping list). Sigl is designed to be intuitive and flexible, emphasizing an ad-hoc approach to shopping lists rather than "recipe" based lists. Simple Grocery List, or **Sigl** (pronounced "sigil") is a lightweight shopping list manager designed for shared grocery lists (or any other shopping list). Sigl is designed to be intuitive and flexible, emphasizing an ad-hoc approach to shopping lists rather than "recipe" based lists.
## Quick Start
Install [Docker](https://www.docker.com/) and
[Docker Compose](https://docs.docker.com/compose/install/) for your platform.
Then run the following commands to clone the Jade Tree repository and run a
local instance of Jade Tree on your machine. Note that the database migration
only has to be done once to set up a fresh database or to upgrade a database to
the latest schema.
```sh
$ git clone https://github.com/asymworks/sigl.git sigl
$ docker-compose -f sigl/docker-compose.yaml up -d
$ docker-compose -f sigl/docker-compose.yaml \
exec app /home/sigl/docker-entry.sh db upgrade
$ docker-compose -f sigl/docker-compose.yaml restart app
```
Then access the Sigl server at http://localhost:5151

18
docker-compose.yaml Normal file
View File

@@ -0,0 +1,18 @@
---
#
# Docker Compose File for Sigl Server
#
version: '3.7'
services:
app:
image: asymworks/sigl:latest
ports:
- 5151:5151
volumes:
- sigl_data:/var/lib/sigl
- ./docker/config.py:/home/sigl/config.py:ro
restart: always
volumes:
sigl_data:

View File

@@ -8,15 +8,11 @@ Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
def init_shell(): # pragma: no cover def init_shell(): # pragma: no cover
"""Initialize the Flask Shell Context.""" """Initialize the Flask Shell Context."""
import datetime import datetime
import sqlalchemy as sa import sqlalchemy as sa
from sigl.database import db from sigl.database import db
from sigl.domain.models import ( from sigl.domain.models import ListEntry, Product, ProductLocation, ShoppingList
ListEntry,
Product,
ProductLocation,
ShoppingList,
)
return { return {
# Imports # Imports

View File

@@ -4,27 +4,18 @@ Simple Grocery List (Sigl) | sigl.app
Copyright (c) 2022 Asymworks, LLC. All Rights Reserved. Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
""" """
from sigl.domain.models import ( from sigl.domain.models import Product, ProductLocation
Product,
ProductLocation,
)
from sigl.domain.models.list import ListEntry, ShoppingList from sigl.domain.models.list import ListEntry, ShoppingList
from .globals import db from .globals import db
from .tables import ( from .tables import list_entries, lists, product_locations, products
list_entries,
lists,
product_locations,
products,
)
__all__ = ('init_orm', ) __all__ = ('init_orm', )
def init_orm(): def init_orm():
"""Initialize the Sigl ORM.""" """Initialize the Sigl ORM."""
# List Entries
# # List Entries
db.mapper(ListEntry, list_entries, properties={ db.mapper(ListEntry, list_entries, properties={
'product': db.relationship( 'product': db.relationship(
Product, Product,

View File

@@ -5,7 +5,7 @@ Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
""" """
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import List, TYPE_CHECKING from typing import TYPE_CHECKING, List
from .mixins import NotesMixin, TimestampMixin from .mixins import NotesMixin, TimestampMixin

View File

@@ -9,6 +9,7 @@ from typing import List, Optional, Union
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from sigl.exc import DomainError, NotFoundError from sigl.exc import DomainError, NotFoundError
from .models import ListEntry, Product, ProductLocation, ShoppingList from .models import ListEntry, Product, ProductLocation, ShoppingList
@@ -140,7 +141,7 @@ def list_stores(session: Session, id: Optional[int]) -> List[str]:
Product has locations are returned. Product has locations are returned.
""" """
if id is None: if id is None:
return list(set([loc.store for loc in session.query(ProductLocation).all()])) return list({loc.store for loc in session.query(ProductLocation).all()})
sList = list_by_id(session, id) sList = list_by_id(session, id)
if not sList: if not sList:

View File

@@ -6,17 +6,32 @@ Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
from flask import ( from flask import (
Blueprint, Blueprint,
flash, jsonify, make_response, redirect, render_template, request, url_for flash,
jsonify,
make_response,
redirect,
render_template,
request,
url_for,
) )
from sigl.exc import DomainError, Error, NotFoundError
from sigl.database import db from sigl.database import db
from sigl.domain.service import ( from sigl.domain.service import (
list_entry_by_id, lists_all, list_by_id, list_create, list_delete, list_addItem,
list_update, list_addItem, list_deleteItem, list_editItem, list_stores, list_by_id,
list_deleteCrossedOff, list_entry_set_crossedOff, list_create,
list_delete,
list_deleteCrossedOff,
list_deleteItem,
list_editItem,
list_entry_by_id,
list_entry_set_crossedOff,
list_stores,
list_update,
lists_all,
products_all, products_all,
) )
from sigl.exc import DomainError, Error, NotFoundError
__all__ = ('bp', ) __all__ = ('bp', )

View File

@@ -4,23 +4,20 @@ Simple Grocery List (Sigl) | sigl.app
Copyright (c) 2022 Asymworks, LLC. All Rights Reserved. Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
""" """
from flask import ( from flask import Blueprint, flash, redirect, render_template, request, url_for
Blueprint,
flash, redirect, render_template, request, url_for
)
from sigl.exc import Error, NotFoundError
from sigl.database import db from sigl.database import db
from sigl.domain.service import ( from sigl.domain.service import (
list_stores, list_stores,
products_all, product_addLocation,
product_by_id, product_by_id,
product_create, product_create,
product_delete, product_delete,
product_update,
product_addLocation,
product_removeLocation, product_removeLocation,
product_update,
products_all,
) )
from sigl.exc import Error, NotFoundError
__all__ = ('bp', ) __all__ = ('bp', )

View File

@@ -6,5 +6,4 @@ Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
from .factory import create_app from .factory import create_app
app = create_app() app = create_app()