Skip to content

Commit

Permalink
Include and Exclude characters shouldn't have a character limit, add …
Browse files Browse the repository at this point in the history
…some constants for sizes common between Forms and Models
  • Loading branch information
AdmiralGT committed Jul 28, 2024
1 parent 16d57d4 commit 65c53a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions scripts/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# A list of constants that should be consistent across database/form usage
MAX_SCRIPT_NAME_LENGTH=100
MAX_AUTHOR_NAME_LENGTH=100
14 changes: 7 additions & 7 deletions scripts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.core.validators import FileExtensionValidator
from versionfield import Version

from scripts import models, script_json, validators, widgets
from scripts import constants, models, script_json, validators, widgets


class JSONError(Exception):
Expand All @@ -17,8 +17,8 @@ def tagOptions():


class ScriptForm(forms.Form):
name = forms.CharField(max_length=100, required=False, label="Script name")
author = forms.CharField(max_length=30, required=False)
name = forms.CharField(max_length=constants.MAX_SCRIPT_NAME_LENGTH, required=False, label="Script name")
author = forms.CharField(max_length=constants.MAX_AUTHOR_NAME_LENGTH, required=False)
script_type = forms.ChoiceField(
choices=models.ScriptTypes.choices, initial=models.ScriptTypes.FULL
)
Expand Down Expand Up @@ -153,13 +153,13 @@ class Meta:


class AdvancedSearchForm(forms.Form):
name = forms.CharField(max_length=100, required=False)
author = forms.CharField(max_length=30, required=False)
name = forms.CharField(max_length=constants.MAX_SCRIPT_NAME_LENGTH, required=False)
author = forms.CharField(max_length=constants.MAX_AUTHOR_NAME_LENGTH, required=False)
script_type = forms.ChoiceField(
choices=models.ScriptTypes.choices, initial=models.ScriptTypes.FULL
)
includes_characters = forms.CharField(max_length=30, required=False)
excludes_characters = forms.CharField(max_length=30, required=False)
includes_characters = forms.CharField(required=False)
excludes_characters = forms.CharField(required=False)
edition = forms.ChoiceField(
choices=models.Edition.choices, initial=models.Edition.CLOCKTOWER_APP
)
Expand Down
5 changes: 3 additions & 2 deletions scripts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.db import models
from versionfield import VersionField

from scripts import constants
from scripts.managers import ScriptViewManager, CollectionManager
from typing import Dict

Expand Down Expand Up @@ -64,7 +65,7 @@ class Script(models.Model):
A named script that can have multiple ScriptVersions
"""

name = models.CharField(max_length=100)
name = models.CharField(max_length=constants.MAX_SCRIPT_NAME_LENGTH)
owner = models.ForeignKey(
User, blank=True, null=True, on_delete=models.SET_NULL, related_name="+"
)
Expand Down Expand Up @@ -92,7 +93,7 @@ class ScriptVersion(models.Model):
script_type = models.CharField(
max_length=20, choices=ScriptTypes.choices, default=ScriptTypes.FULL
)
author = models.CharField(max_length=100, null=True, blank=True)
author = models.CharField(max_length=constants.MAX_AUTHOR_NAME_LENGTH, null=True, blank=True)
version = VersionField()
content = models.JSONField()
pdf = models.FileField(null=True, blank=True, upload_to=determine_script_location)
Expand Down

0 comments on commit 65c53a2

Please sign in to comment.