Skip to content

Commit

Permalink
Merge pull request #325 from opengisch/postrelease_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
suricactus committed May 10, 2022
1 parent b2b0f5d commit 6d3ab76
Show file tree
Hide file tree
Showing 7 changed files with 422 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docker-app/qfieldcloud/core/migrations/0052_secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class Migration(migrations.Migration):
(
"name",
models.TextField(
help_text="Must start with a letter and followed by capital letters, numbers or underscores.",
help_text="Must start with a capital letter and followed by capital letters, numbers or underscores.",
max_length=255,
unique=True,
validators=[
django.core.validators.RegexValidator(
"^[A-Z]+[A-Z0-9_]+$",
"Must start with a letter and followed by capital letters, numbers or underscores.",
"Must start with a capital letter and followed by capital letters, numbers or underscores.",
)
],
),
Expand Down
38 changes: 38 additions & 0 deletions docker-app/qfieldcloud/core/migrations/0054_auto_20220505_1948.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 3.2.13 on 2022-05-05 17:48

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("core", "0053_project_last_package"),
]

operations = [
migrations.AlterModelOptions(
name="secret",
options={"ordering": ["project", "name"]},
),
migrations.AlterField(
model_name="secret",
name="name",
field=models.TextField(
help_text="Must start with a capital letter and followed by capital letters, numbers or underscores.",
max_length=255,
validators=[
django.core.validators.RegexValidator(
"^[A-Z]+[A-Z0-9_]+$",
"Must start with a capital letter and followed by capital letters, numbers or underscores.",
)
],
),
),
migrations.AddConstraint(
model_name="secret",
constraint=models.UniqueConstraint(
fields=("project", "name"), name="secret_project_name_uniq"
),
),
]
13 changes: 10 additions & 3 deletions docker-app/qfieldcloud/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,18 +1283,17 @@ class Type(models.TextChoices):

name = models.TextField(
max_length=255,
unique=True,
validators=[
RegexValidator(
r"^[A-Z]+[A-Z0-9_]+$",
_(
"Must start with a letter and followed by capital letters, numbers or underscores."
"Must start with a capital letter and followed by capital letters, numbers or underscores."
),
)
],
help_text=_(
_(
"Must start with a letter and followed by capital letters, numbers or underscores."
"Must start with a capital letter and followed by capital letters, numbers or underscores."
),
),
)
Expand All @@ -1308,6 +1307,14 @@ class Type(models.TextChoices):
created_at = models.DateTimeField(auto_now_add=True)
value = django_cryptography.fields.encrypt(models.TextField())

class Meta:
ordering = ["project", "name"]
constraints = [
models.UniqueConstraint(
fields=["project", "name"], name="secret_project_name_uniq"
)
]


auditlog.register(User, exclude_fields=["last_login", "updated_at"])
auditlog.register(UserAccount)
Expand Down
2 changes: 0 additions & 2 deletions docker-app/qfieldcloud/core/permissions_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ def can_create_secrets(user: QfcUser, project: Project) -> bool:
project,
[
ProjectCollaborator.Roles.ADMIN,
ProjectCollaborator.Roles.MANAGER,
],
)

Expand All @@ -347,7 +346,6 @@ def can_delete_secrets(user: QfcUser, project: Project) -> bool:
project,
[
ProjectCollaborator.Roles.ADMIN,
ProjectCollaborator.Roles.MANAGER,
],
)

Expand Down
20 changes: 18 additions & 2 deletions docker-app/qfieldcloud/core/tests/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,28 @@ def test_connects_via_pgservice(self):
self.conn.commit()

Secret.objects.create(
name="PG_SERVICE_GEODB",
name="PG_SERVICE_GEODB1",
type=Secret.Type.PGSERVICE,
project=self.project1,
created_by=self.project1.owner,
value=(
"[geodb]\n"
"[geodb1]\n"
"dbname=test\n"
"host=geodb\n"
"port=5432\n"
f"user={os.environ.get('GEODB_USER')}\n"
f"password={os.environ.get('GEODB_PASSWORD')}\n"
"sslmode=disable\n"
),
)

Secret.objects.create(
name="PG_SERVICE_GEODB2",
type=Secret.Type.PGSERVICE,
project=self.project1,
created_by=self.project1.owner,
value=(
"[geodb2]\n"
"dbname=test\n"
"host=geodb\n"
"port=5432\n"
Expand Down
Loading

0 comments on commit 6d3ab76

Please sign in to comment.