Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
max_line_length = 120
trim_trailing_whitespace = true
indent_style = space
quote_type = single
curly_bracket_next_line = true
spaces_around_operators = true
1indent_brace_style = TBS

[*.html]
indent_size = 4
quote_type = double

[*.py]
indent_size = 4

[Makefile]
indent_style = tab

[*.{js, jsx, vue}]
indent_size = 2

[{package.json, .travis.yml}]
indent_size = 2
28 changes: 28 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 12
},
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ static
*.dat
.env
.idea/
fortytwo_test_task/local_settings.py
fortytwo_test_task/settings/local.py
/node_modules/
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ shell:
@echo Starting shell...
$(MANAGE) shell

flake8:
lint:
./bin/check_noqa.sh
./bin/check_layout.sh
jinjalint templates
$(flake8) apps
black apps

djangotest:
TESTING=1 PYTHONWARNINGS=ignore $(MANAGE_CMD) test --settings=$(TEST_SETTINGS) $(TEST_APP)

test: flake8 djangotest
test: lint djangotest

collectstatic: clean
@echo Collecting static
Expand All @@ -69,5 +73,5 @@ migrate:
migrations:
$(MANAGE) makemigrations

check_noqa:
./check_noqa.sh
eslint:
node_modules/.bin/eslint .
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
42-test template
===========================

A Django 1.6+ project template
A Django 3+ project template

Use fortytwo_test_task.settings when deploying with getbarista.com

### Recomendations
### Requirements
* apps in apps/ folder
* use per-app templates folders
* use per-app static folders
* use migrations
* use settings.local for different environments
* common templates live in templates/
* common static lives in assets/
* use local.py for different local settings
* templates live in templates/
* static lives in assets/
* management commands should be proxied to single word make commands, e.g make test

* run `make lint` often
* installed node and yarn. after cloning the project run `yarn`
* lint your js, run `make eslint`
7 changes: 7 additions & 0 deletions bin/check_layout.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

fnd=$(find apps -type f -name "*.html")
[ "$fnd" ] && echo "Templates should be in /templates" && exit 1
fnd=$(find apps -type f -name "*.js" -o -name "*.css")
[ "$fnd" ] && echo "Assets should be in /assets" && exit 1
exit 0
11 changes: 11 additions & 0 deletions bin/check_noqa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

fnd=$(grep -rin --exclude="apps.py" "\bnoqa\b" apps)

if [ "$fnd" ]; then
echo "WARNING: noqa statements were found"
echo "${fnd}"
exit 1
else
exit 0
fi
10 changes: 0 additions & 10 deletions check_noqa.sh

This file was deleted.

2 changes: 1 addition & 1 deletion fortytwo_test_task/settings/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .common import *
from .common import * # noqa

DATABASES = {
'default': {
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"eslint": "^7.10.0"
}
}
23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[tool.black]
line-length = 120
target-version = ['py37']
include = '\.pyi?$'
skip-string-normalization = true
check = true
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| migrations/*
)/
)
'''
15 changes: 15 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
Django==3.0.8
jinjalint==0.5
42cc-pystyle
black==20.8b1
flake8==3.8.3
flake8-black==0.2.1
flake8-broken-line==0.2.1
flake8-cognitive-complexity==0.1.0
flake8-commas==2.0.0
flake8-django==1.1.1
flake8-eradicate==0.4.0
flake8-mutable==1.2.0
flake8-polyfill==1.0.2
flake8-print==3.1.4
flake8-quotes==3.2.0
flake8-variables-names==0.0.3
flake8-walrus==1.1.0
Loading