Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
60c3c1b34b | ||
![]() |
d6697e0f08 | ||
![]() |
418f0144ab | ||
![]() |
07c3ebc7e0 | ||
![]() |
904a81b38f | ||
![]() |
ebdedd3643 | ||
![]() |
4366780069 | ||
![]() |
c8b54eab16 |
7 changed files with 102 additions and 79 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -18,10 +18,6 @@
|
||||||
# vim tmp files
|
# vim tmp files
|
||||||
*~
|
*~
|
||||||
|
|
||||||
# org poznamky
|
|
||||||
schemata
|
|
||||||
TODO
|
|
||||||
|
|
||||||
# .htpasswd kvůli přihlášení
|
# .htpasswd kvůli přihlášení
|
||||||
.htpasswd
|
.htpasswd
|
||||||
|
|
||||||
|
@ -36,4 +32,4 @@ TODO
|
||||||
|
|
||||||
# dokumentace
|
# dokumentace
|
||||||
docs/_build
|
docs/_build
|
||||||
docs/modules
|
docs/modules
|
||||||
|
|
82
README.md
82
README.md
|
@ -1,77 +1,11 @@
|
||||||
Basic commands for web development
|
# DO NOT MERGE!
|
||||||
==================================
|
|
||||||
|
|
||||||
After you clone this repository, run `make`. It will download, locally install
|
LEdoianova větev s random nástroji. Rozhodně ji nechcete mergenout, pokud se
|
||||||
and setup virtualenv and pip, and then locally install all required packages
|
tenhle text někde objeví, tak je to špatně :-)
|
||||||
from `requirements.txt`.
|
|
||||||
|
|
||||||
When working with the code, always use the binaries in `./bin/`, such as
|
|
||||||
`bin/pip`, `bin/python`, ... never the global python, pip, ...
|
|
||||||
Use `make` and `./manage.py` for most things.
|
|
||||||
|
|
||||||
Use git :-)
|
|
||||||
|
|
||||||
Quickstart
|
|
||||||
----------
|
|
||||||
Run the following commands:
|
|
||||||
make install_venv
|
|
||||||
. env/bin/activate
|
|
||||||
make install_web
|
|
||||||
|
|
||||||
Pokud install_web říká Error: pg_config executable not found. nainstaluj si libpq-dev
|
|
||||||
Pokud chybová hláška obsahuje #include <Python.h>, nainstaluj si python3-dev
|
|
||||||
|
|
||||||
After finishing development, run "deactivate".
|
|
||||||
|
|
||||||
Make commands
|
|
||||||
-------------
|
|
||||||
|
|
||||||
* `make install` (or `make`) - locally install and setup virtualpy, install
|
|
||||||
required packages. Ran again installs missing packages. Run after changing
|
|
||||||
`requirements.txt`.
|
|
||||||
|
|
||||||
* `make clean` - remove local python packages.
|
|
||||||
|
|
||||||
* `make veryclean` - remove local packages and virtualpy enviroment and
|
|
||||||
binaries.
|
|
||||||
|
|
||||||
* `make run` - runs "./manage.py runserver_plus"
|
|
||||||
|
|
||||||
* `make push_test` - pushes the last commited version to test location.
|
|
||||||
Only git-commited changes are pushed! Rest is re-generated from scratch.
|
|
||||||
At test server, the media data and database are kept the same.
|
|
||||||
Everything else not in .gitignore is deleted/overwritten on the test server.
|
|
||||||
|
|
||||||
* `make schema` - generates graph of seminar and all schemas as PDF. Supercool!
|
|
||||||
|
|
||||||
* `make sync_prod_flatpages` - downloads and applies static/flat pages from mamweb-prod
|
|
||||||
|
|
||||||
./manage.py commands
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
* `./manage.py migrate` - update the database schema, initialise the database.
|
|
||||||
You need to run this in the beginning.
|
|
||||||
|
|
||||||
* `./manage.py runserver_plus` - run a debugging server for the web. Slightly
|
|
||||||
enhanced compared to `./manage.py runserver`.
|
|
||||||
Open [127.0.0.1:8000](127.0.0.1:8000).
|
|
||||||
|
|
||||||
* `./manage.py testdata` - create pseudo-random seminar data and admin/admin
|
|
||||||
user.
|
|
||||||
|
|
||||||
* `./manage.py test` - run the tests.
|
|
||||||
|
|
||||||
* `./manage.py shell` - run commands, list elemements of database, check syntax
|
|
||||||
by importing files, etc.
|
|
||||||
|
|
||||||
Configurations
|
|
||||||
--------------
|
|
||||||
|
|
||||||
* `mamweb/settings_common.py` contains most configuration options.
|
|
||||||
* `mamweb/settings.py` is used only for local development.
|
|
||||||
* `mamweb/settings_test.py` is used for testing on atrey.
|
|
||||||
* `mamweb/settings_prod.py` is used in production deployment.
|
|
||||||
|
|
||||||
These are automatically switched by `make`.
|
|
||||||
|
|
||||||
|
Nástroje jsou pro _moji_ vlastní potřebu, **za nic neručím**, do jiných větví
|
||||||
|
je cherry-picknu, až budou hotové a pokud budou užitečné i někomu dalšímu.
|
||||||
|
Nebojte se inspirovat, ale nezaručuju ani funkční, ani hezký, ani spustitelný
|
||||||
|
kód.
|
||||||
|
|
||||||
|
TL;DR: prostě ten kód ani nezkoušejte spustit, nebo se nedivte :-)
|
||||||
|
|
6
TODO
Normal file
6
TODO
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
Výroba Problémů
|
||||||
|
Kontrola starých orgů
|
||||||
|
Témátka do filtru řešení
|
||||||
|
Proklikávací řešitelé
|
||||||
|
|
||||||
|
Symbolika
|
10
make/init_local
Executable file
10
make/init_local
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -exuo pipefail
|
||||||
|
. make/lib.sh
|
||||||
|
|
||||||
|
make/install_web
|
||||||
|
ensure_venv
|
||||||
|
./manage.py testdata
|
||||||
|
./manage.py loaddata data/*
|
||||||
|
make/sync_prod_flatpages
|
22
mkdocs.sh
Executable file
22
mkdocs.sh
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
commit="$(git rev-parse "$1^{commit}")"
|
||||||
|
|
||||||
|
tmp="$(mktemp --directory)"
|
||||||
|
trap "rm -rvf \"$tmp\"" EXIT
|
||||||
|
|
||||||
|
# c-o
|
||||||
|
git worktree add "$tmp" "$commit"
|
||||||
|
trap "git worktree remove \"$tmp\"" EXIT
|
||||||
|
cd "$tmp"
|
||||||
|
|
||||||
|
# make
|
||||||
|
cd docs
|
||||||
|
make html
|
||||||
|
|
||||||
|
# rsync
|
||||||
|
rsync -raAXP _build/html/ "Gimli:WWW/mwd/$commit/"
|
||||||
|
ssh Gimli "chmod -R o+rX WWW/mwd/$commit"
|
||||||
|
|
||||||
|
echo Done.
|
35
rangeset.py
Executable file
35
rangeset.py
Executable file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/python3
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class RangeSet:
|
||||||
|
def __init__(self, rangespec):
|
||||||
|
self.ranges = self.parse_spec(rangespec)
|
||||||
|
def __contains__(self, num):
|
||||||
|
return any(num in r for r in self.ranges)
|
||||||
|
def parse_spec(self, spec: str) -> list[range]:
|
||||||
|
result = []
|
||||||
|
parts = spec.split(',')
|
||||||
|
parts = map(str.strip, parts)
|
||||||
|
for part in parts:
|
||||||
|
if '-' in part:
|
||||||
|
start, end = part.split('-')
|
||||||
|
result.append(range(int(start), int(end)+1))
|
||||||
|
else:
|
||||||
|
n = int(part)
|
||||||
|
result.append(range(n, n+1))
|
||||||
|
return result
|
||||||
|
# TODO: iteration. Will require deduplication.
|
||||||
|
# TODO: simplification of inner ranges
|
||||||
|
# TODO: Set operations: union, intersection, difference?
|
||||||
|
# TODO: Comparison to classic range objects (only to check that it represents the same numbers)
|
||||||
|
|
||||||
|
class TestRangeSetBasic(unittest.TestCase):
|
||||||
|
def test_number_sequence(self):
|
||||||
|
rs = RangeSet('1,3,4,5')
|
||||||
|
for x in [1,3,4,5]:
|
||||||
|
self.assertIn(x, rs)
|
||||||
|
self.assertNotIn(2, rs)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print('This is a library. Runing the testsuite instead.')
|
||||||
|
unittest.main()
|
20
vyroba_problemu/snippet_z_Gimliho.py
Normal file
20
vyroba_problemu/snippet_z_Gimliho.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
with transaction.atomic():
|
||||||
|
assert t.id == 2365
|
||||||
|
pfx = f"{t.nazev}, "
|
||||||
|
# Problémy
|
||||||
|
for k, b in [(4,3)]:
|
||||||
|
u = m.Uloha.objects.create(
|
||||||
|
nadproblem=t,
|
||||||
|
nazev=pfx + f"{'úloha' if b is not None else 'problém'} {k}",
|
||||||
|
autor=t.autor,
|
||||||
|
garant=t.garant,
|
||||||
|
max_body=b,
|
||||||
|
cislo_zadani=m.Cislo.get(28, 5),
|
||||||
|
kod=k,
|
||||||
|
stav=m.Problem.STAV_ZADANY,
|
||||||
|
)
|
||||||
|
u.opravovatele.set(t.opravovatele.all())
|
||||||
|
print(u, u.max_body)
|
||||||
|
input("rly?")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue