Compare commits

...

8 Commits

Author SHA1 Message Date
Pavel "LEdoian" Turinsky 60c3c1b34b Zrušení nepotřebností v .gitignore _NA MÉ VĚTVI_. 12 months ago
Pavel "LEdoian" Turinsky d6697e0f08 Moje soukromé TODO 12 months ago
Pavel "LEdoian" Turinsky 418f0144ab todo… 1 year ago
Pavel "LEdoian" Turinsky 07c3ebc7e0 Přidána knihovna na parsování rozsahů (WIP) 1 year ago
Pavel 'LEdoian' Turinsky 904a81b38f make: instalace celého lokálního webu 2 years ago
Pavel "LEdoian" Turinsky ebdedd3643 Snippet, kterým jsme někdy generovali problémy v ipythonu 2 years ago
Pavel "LEdoian" Turinsky 4366780069 Skript na automatické buildy dokumentace různých větví / commitů 2 years ago
Pavel "LEdoian" Turinsky c8b54eab16 Místo README je disclaimer :-) 2 years ago
  1. 6
      .gitignore
  2. 82
      README.md
  3. 6
      TODO
  4. 10
      make/init_local
  5. 22
      mkdocs.sh
  6. 35
      rangeset.py
  7. 20
      vyroba_problemu/snippet_z_Gimliho.py

6
.gitignore

@ -18,10 +18,6 @@
# vim tmp files
*~
# org poznamky
schemata
TODO
# .htpasswd kvůli přihlášení
.htpasswd
@ -36,4 +32,4 @@ TODO
# dokumentace
docs/_build
docs/modules
docs/modules

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
and setup virtualenv and pip, and then locally install all required packages
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`.
LEdoianova větev s random nástroji. Rozhodně ji nechcete mergenout, pokud se
tenhle text někde objeví, tak je to špatně :-)
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

@ -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

@ -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

@ -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

@ -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

@ -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…
Cancel
Save