Skip to content

Commit

Permalink
Merge pull request #10 from opengisch/projectname_libre
Browse files Browse the repository at this point in the history
Letters, numbers, underscores, hyphens and dots are allowed in project names
  • Loading branch information
suricactus authored May 9, 2021
2 parents 9a0beb2 + 2658b8a commit 31d0c50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions docker-app/qfieldcloud/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from django.contrib.auth.models import AbstractUser, UserManager
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.db import models
from django.db.models import Case, Exists, OuterRef, Q
from django.db.models import Value as V
Expand Down Expand Up @@ -518,13 +519,13 @@ class Meta:
name = models.CharField(
max_length=255,
validators=[
validators.allowed_symbols_validator,
validators.min_lenght_validator,
validators.first_symbol_validator,
validators.reserved_words_validator,
RegexValidator(
r"^[a-zA-Z0-9-_\.]+$",
_("Only letters, numbers, underscores, hyphens and dots are allowed."),
)
],
help_text=_(
"Project name. Should start with a letter and contain only letters, numbers, underscores and hyphens."
_("Only letters, numbers, underscores, hyphens and dots are allowed.")
),
)

Expand Down
4 changes: 2 additions & 2 deletions docker-app/qfieldcloud/core/tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ def test_create_project(self):

self.assertEqual(str(project.owner), "user1")

def test_create_project_reserved_name(self):
def test_create_project_invalid_name(self):
self.client.credentials(HTTP_AUTHORIZATION="Token " + self.token1.key)
response = self.client.post(
"/api/v1/projects/",
{
"name": "project",
"name": "project$",
"owner": "user1",
"description": "desc",
"is_public": False,
Expand Down

0 comments on commit 31d0c50

Please sign in to comment.