diff --git a/README.rst b/README.rst index 61761c84..02bb5518 100644 --- a/README.rst +++ b/README.rst @@ -16,29 +16,58 @@ file on the production server):: SENTRY_DSN= ALLOWED_HOSTS=["*"] DEBUG=True + LIVE=False NAMESPACE=feinheit OAUTH2_CLIENT_ID=... OAUTH2_CLIENT_SECRET=... -Prerequisites: +Prerequisites +============= -* At least Python 3.8 -* Install `fh-fablib `__ -* Local PostgreSQL and Redis instances +* At least Python 3.11 +* A local PostgreSQL instance -Local setup:: +Local setup +=========== - fl local - fl pull-db # Only if you have access to our server, sorry. + python3 -m venv venv + . venv/bin/activate + pip install -U pip + pip install -r requirements.txt -Development:: + ./manage.py prepare + ./manage.py createsuperuser - fl dev +Development +=========== -Code style & prettification:: + ./manage.py runserver - fl fmt check +Then, visit http://127.0.0.1:8000/accounts/login/?force_login=EMAIL in your +browser and replace ``EMAIL`` with the email address you used when creating the +superuser. Note that this only works when you're running with ``DEBUG=True`` +**and** ``LIVE=False``, this never works in a production environment. -Compile the bootstrap library:: +You should probably visit the admin panel now and add a few service types incl. +their hourly rate at http://127.0.0.1:8000/admin/services/servicetype/ - yarn build-bootstrap +The admin panel is configured mostly as a read-only interface to your data, +except for the few modules where the admin panel actually works as a management +interface. + +Next, visit the contacts list, add an organization, a person working at that +organization, and then you're ready to start adding projects, services etc. + +Deployment +========== + +I am deploying Workbench as a container, the necessary containerfile is a part +of this repository. Instead of using an ``.env`` file you should provide the +configuration through environment variables some other way. Workbench sends a +few mails directly through SMTP, so you should probably add the appropriate +``EMAIL_URL`` configuration. See +https://github.com/matthiask/speckenv/blob/main/test_speckenv_django_email_url.py +for examples. + +You should set up a cronjob which runs ``./manage.py fairy_tasks`` daily. This +is a requirement for the recurring invoices functionality and other things. diff --git a/workbench/accounts/models.py b/workbench/accounts/models.py index 9b55ec50..1565e473 100644 --- a/workbench/accounts/models.py +++ b/workbench/accounts/models.py @@ -113,7 +113,6 @@ def active(self): @total_ordering class User(Model, AbstractBaseUser): USERNAME_FIELD = "email" - REQUIRED_FIELDS = ["working_time_model"] email = models.EmailField(_("email"), max_length=254, unique=True) is_active = models.BooleanField(_("is active"), default=True) diff --git a/workbench/management/commands/prepare.py b/workbench/management/commands/prepare.py new file mode 100644 index 00000000..3504c579 --- /dev/null +++ b/workbench/management/commands/prepare.py @@ -0,0 +1,12 @@ +from django.core.management.base import BaseCommand + +from workbench.awt.models import WorkingTimeModel + + +class Command(BaseCommand): + help = "Prepare for the createsuperuser command" + + def handle(self, **options): + wt = WorkingTimeModel.objects.first() + if not wt: + wt = WorkingTimeModel.objects.create(name="Arbeitszeitmodell")