Compare commits

..

2 commits

8 changed files with 20 additions and 100 deletions

View file

@ -69,14 +69,10 @@ export PYTHONPATH="${PYTHONPATH}:/usr/lib/python3/dist-packages"
#### Environment Variables #### Environment Variables
Now, configure the environment variables. For this, we will expand a `.env` file. You can use the following content as an example: Now, configure the environment variables. For this, we will expand a `.env` file. For a quickstart with localhost, you can use the default values in the `.env.example` file:
```source ```bash
STATIC_ROOT=/tmp/static/ cp .env.example .env
MEDIA_ROOT=/tmp/media/
ALLOWED_HOSTS=localhost,localhost:8000,127.0.0.1,
DOMAIN=localhost
DEBUG=True
``` ```
Now, expand the environment variables: Now, expand the environment variables:

View file

@ -32,11 +32,11 @@ SECRET_KEY = "django-insecure-1p8rs@qf$$l^!vsbetagojw23kw@1ez(qi8^(s0t&#7!wyh!l3
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default=False, cast=bool) DEBUG = config('DEBUG', default=False, cast=bool)
DOMAIN = config("DOMAIN") DEVICEHUB_DOMAIN = config("DEVICEHUB_DOMAIN")
assert DOMAIN not in [None, ''], "DOMAIN var is MANDATORY" assert DEVICEHUB_DOMAIN not in [None, ''], "DEVICEHUB_DOMAIN var is MANDATORY"
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=DOMAIN, cast=Csv()) ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=DEVICEHUB_DOMAIN, cast=Csv())
assert DOMAIN in ALLOWED_HOSTS, f"DOMAIN {DOMAIN} is not in ALLOWED_HOSTS {ALLOWED_HOSTS}" assert DEVICEHUB_DOMAIN in ALLOWED_HOSTS, f"DEVICEHUB_DOMAIN {DEVICEHUB_DOMAIN} is not in ALLOWED_HOSTS {ALLOWED_HOSTS}"
CSRF_TRUSTED_ORIGINS = config('CSRF_TRUSTED_ORIGINS', default=f'https://{DOMAIN}', cast=Csv()) CSRF_TRUSTED_ORIGINS = config('CSRF_TRUSTED_ORIGINS', default=f'https://{DOMAIN}', cast=Csv())

View file

@ -147,7 +147,6 @@ run_demo() {
'example/demo-snapshots-vc/snapshot_pre-verifiable-credential.json' \ 'example/demo-snapshots-vc/snapshot_pre-verifiable-credential.json' \
> 'example/snapshots/snapshot_workbench-script_verifiable-credential.json' > 'example/snapshots/snapshot_workbench-script_verifiable-credential.json'
fi fi
./manage.py create_default_states "${INIT_ORG}"
/usr/bin/time ./manage.py up_snapshots example/snapshots/ "${INIT_USER}" /usr/bin/time ./manage.py up_snapshots example/snapshots/ "${INIT_USER}"
} }

View file

@ -1,18 +0,0 @@
# Generated by Django 5.0.6 on 2025-02-25 12:32
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('lot', '0007_lottag_inbox'),
]
operations = [
migrations.RenameField(
model_name='lot',
old_name='closed',
new_name='archived',
),
]

View file

@ -32,7 +32,7 @@ class Lot(models.Model):
name = models.CharField(max_length=STR_SIZE, blank=True, null=True) name = models.CharField(max_length=STR_SIZE, blank=True, null=True)
code = models.CharField(max_length=STR_SIZE, blank=True, null=True) code = models.CharField(max_length=STR_SIZE, blank=True, null=True)
description = models.CharField(max_length=STR_SIZE, blank=True, null=True) description = models.CharField(max_length=STR_SIZE, blank=True, null=True)
archived = models.BooleanField(default=False) closed = models.BooleanField(default=False)
owner = models.ForeignKey(Institution, on_delete=models.CASCADE) owner = models.ForeignKey(Institution, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True) user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
type = models.ForeignKey(LotTag, on_delete=models.CASCADE) type = models.ForeignKey(LotTag, on_delete=models.CASCADE)

View file

@ -7,13 +7,13 @@
<h3>{{ subtitle }}</h3> <h3>{{ subtitle }}</h3>
</div> </div>
<div class="col text-center"> <div class="col text-center">
{% if show_archived %} {% if show_closed %}
<a href="?show_archived=false" class="btn btn-green-admin"> <a href="?show_closed=false" class="btn btn-green-admin">
{% trans 'Show active lots' %} {% trans 'Hide closed lots' %}
</a> </a>
{% else %} {% else %}
<a href="?show_archived=true" class="btn btn-green-admin"> <a href="?show_closed=true" class="btn btn-green-admin">
{% trans 'Show archived lots' %} {% trans 'Show closed lots' %}
</a> </a>
{% endif %} {% endif %}

View file

@ -25,7 +25,7 @@ class NewLotView(DashboardView, CreateView):
"name", "name",
"code", "code",
"description", "description",
"archived", "closed",
) )
def get_form(self): def get_form(self):
@ -54,7 +54,7 @@ class DeleteLotView(DashboardView, DeleteView):
"name", "name",
"code", "code",
"description", "description",
"archived", "closed",
) )
def form_valid(self, form): def form_valid(self, form):
@ -73,7 +73,7 @@ class EditLotView(DashboardView, UpdateView):
"name", "name",
"code", "code",
"description", "description",
"archived", "closed",
) )
def get_form_kwargs(self): def get_form_kwargs(self):
@ -149,15 +149,15 @@ class LotsTagsView(DashboardView, TemplateView):
tag = get_object_or_404(LotTag, owner=self.request.user.institution, id=self.pk) tag = get_object_or_404(LotTag, owner=self.request.user.institution, id=self.pk)
self.title += " {}".format(tag.name) self.title += " {}".format(tag.name)
self.breadcrumb += " {}".format(tag.name) self.breadcrumb += " {}".format(tag.name)
show_archived = self.request.GET.get('show_archived', 'false') == 'true' show_closed = self.request.GET.get('show_closed', 'false') == 'true'
lots = Lot.objects.filter(owner=self.request.user.institution).filter( lots = Lot.objects.filter(owner=self.request.user.institution).filter(
type=tag, archived=show_archived type=tag, closed=show_closed
) )
context.update({ context.update({
'lots': lots, 'lots': lots,
'title': self.title, 'title': self.title,
'breadcrumb': self.breadcrumb, 'breadcrumb': self.breadcrumb,
'show_archived': show_archived 'show_closed': show_closed
}) })
return context return context

View file

@ -1,6 +1,6 @@
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from user.models import Institution from user.models import Institution
from lot.models import LotTag, Lot from lot.models import LotTag
class Command(BaseCommand): class Command(BaseCommand):
@ -12,7 +12,6 @@ class Command(BaseCommand):
def handle(self, *args, **kwargs): def handle(self, *args, **kwargs):
self.institution = Institution.objects.create(name=kwargs['name']) self.institution = Institution.objects.create(name=kwargs['name'])
self.create_lot_tags() self.create_lot_tags()
self.create_lots()
def create_lot_tags(self): def create_lot_tags(self):
LotTag.objects.create( LotTag.objects.create(
@ -30,59 +29,3 @@ class Command(BaseCommand):
name=tag, name=tag,
owner=self.institution owner=self.institution
) )
def create_lots(self):
for g in LotTag.objects.all():
if g.name == "Entrada":
Lot.objects.create(
name="donante-orgA",
owner=self.institution,
archived=True,
type=g
)
Lot.objects.create(
name="donante-orgB",
owner=self.institution,
type=g
)
Lot.objects.create(
name="donante-orgC",
owner=self.institution,
type=g
)
if g.name == "Salida":
Lot.objects.create(
name="beneficiario-org1",
owner=self.institution,
type=g
)
Lot.objects.create(
name="beneficiario-org2",
owner=self.institution,
archived=True,
type=g
)
Lot.objects.create(
name="beneficiario-org3",
owner=self.institution,
type=g
)
if g.name == "Temporal":
Lot.objects.create(
name="palet1",
owner=self.institution,
type=g
)
Lot.objects.create(
name="palet2",
owner=self.institution,
type=g
)
Lot.objects.create(
name="palet3",
owner=self.institution,
archived=True,
type=g
)