Skip to content

Commit

Permalink
Fix, update, squash, clean up
Browse files Browse the repository at this point in the history
Add tests and documentation too.
  • Loading branch information
IvanAnishchuk committed Nov 13, 2018
1 parent 0bbb036 commit bb936cf
Show file tree
Hide file tree
Showing 113 changed files with 3,876 additions and 1,639 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[run]
branch = True
include = pizzeria_dangelo/*
omit = *migrations*, *tests*
plugins =
Expand Down
14 changes: 0 additions & 14 deletions .pylintrc

This file was deleted.

10 changes: 8 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Django = {extras = ["argon2"], version = "*"}
Pillow = "*"
requests = "*"
drf-writable-nested = "*"
"flake8-mypy" = "*"
raven = "*"

[dev-packages]
django-debug-toolbar = "*"
Expand Down Expand Up @@ -52,10 +52,16 @@ Werkzeug = "*"
Sphinx = "*"
factory_boy = "*"
django_coverage_plugin = "*"
"flake8-broken-line" = "*"
"flake8-commas" = "*"
"flake8-bandit" = "*"
"flake8-broken-line" = "*"
"flake8-mypy" = "*"
"flake8-tuple" = "*"
pytest-coverage = "*"
pylint = "*"
pylint-django = "*"
pylint-celery = "*"
pycodestyle = "*"

[requires]
python_version = "3.7"
420 changes: 229 additions & 191 deletions Pipfile.lock

Large diffs are not rendered by default.

28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This api backend is a simple example of using HATEOAS and a couple other
design patterns. First of all, everything has a unique ID here, even two
(uid set on creation, mid changes on every modification) which can be
considered extremely long timestamps and everything that has name also has a
slug. Thus, whenever slug is present it's used in the urls otherwise uid is
slug. Thus, whenever slug is present it's used in the urls, otherwise uid is
used (it looks like uuid and can be handled by uuid-optimized tools but
doesn't share some standard uuid issues, like this ids aare alphabetically
sortable by creation/modification time). JSON (or otherwise encoded) content
Expand All @@ -19,6 +19,28 @@ There are not authentication/authorization and almost no validation. Models and
api endpoints structure were the focus of this work. Most of the api code is
default, only a couple things are custom.

I'm also trying several new approaches here and all the dependencies are fresh,
I'm trying out type hints, f-strings, new django, and other things. Some worked
out great, some could definitely be improved further.

## Instructions

`pipenv install` and `pipenv install -d` will set the virtualenv for you. It's
possible to generate compatibility requirements.txt files but at the moment I'm
trying to avoid it. To activate it run `pipenv shell`

After that `./manage.py runserver` and others work as usual.

(You might need to set a few env variables in .env files or shell environment,
like database url.)

`pytest` runs tests, `flake8` and something like
`pylint pizzeria_dangelo/ utils/ config/ *.py` (yeah, I know, pylint)
are there for static checks. flake8 plugins include mypy and bandit.

`coverage run -m pytest && coverage html && open htmlcov/index.html` is one of
the ways to check test coverage.

## Boring notes

Ok, this project is not made for a real business, rather it's designed based
Expand All @@ -35,5 +57,5 @@ even if something doesn't quite work, it can be made to work in little to no
time should the need ever arise.

Yeah, I used cookiecutter-django for scaffolding, it created a few things that
are not currently utilized and I'm lazy to clean them up (besides, I might need
them if I decide to do any further development).
are not currently utilized and I'm too lazy to clean them up (besides, I might
need them if I decide to do any further development).
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
'utils.renderers.BrowsableAPIRenderer', # XXX: disable on production
],
'PAGE_SIZE': 10,
'EXCEPTION_HANDLER': 'utils.views.exception_handler',
}
# Your stuff...
# ------------------------------------------------------------------------------
27 changes: 12 additions & 15 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@
from django.views import defaults as default_views
from rest_framework import routers

import customer_orders.views
import pizza.views
import pizzeria_dangelo.customer_orders.views
import pizzeria_dangelo.pizza.views
import pizzeria_dangelo.extras.views

router = routers.DefaultRouter()
router.register(r'sizes', pizza.views.PizzaSizeViewSet)
router.register(r'crusts', pizza.views.PizzaCrustViewSet)
router.register(r'toppings', pizza.views.PizzaToppingViewSet)
router.register(r'pizzacomponents', pizza.views.PizzaComponentViewSet)
router.register(r'pizzas', pizza.views.PizzaViewSet)
router.register(r'orders', customer_orders.views.OrderViewSet)
router.register(r'sizes', pizzeria_dangelo.pizza.views.PizzaSizeViewSet)
router.register(r'crusts', pizzeria_dangelo.pizza.views.PizzaCrustViewSet)
router.register(r'toppings', pizzeria_dangelo.pizza.views.PizzaToppingViewSet)
router.register(r'pizzacomponents', pizzeria_dangelo.pizza.views.PizzaComponentViewSet)
router.register(r'pizzas', pizzeria_dangelo.pizza.views.PizzaViewSet)
router.register(r'extras', pizzeria_dangelo.extras.views.ExtraViewSet)
router.register(r'extracategories', pizzeria_dangelo.extras.views.ExtraCategoryViewSet)
router.register(r'orders', pizzeria_dangelo.customer_orders.views.OrderViewSet)


urlpatterns = [
path("", RedirectView.as_view(url="/api/1/")),
# path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
# path(
# "about/",
# TemplateView.as_view(template_name="pages/about.html"),
# name="about",
# ),
path("", RedirectView.as_view(url="/api/1/"), name="home"),
# Django Admin, use {% url 'admin:index' %}
path(settings.ADMIN_URL, admin.site.urls),
# User management
Expand Down
Loading

0 comments on commit bb936cf

Please sign in to comment.