handling special chars in solution
This commit is contained in:
parent
cdf977f0db
commit
b4ab4809c6
5 changed files with 22 additions and 2 deletions
2
Ideen.md
2
Ideen.md
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
- api/ui: Türchen mit Tag "0" einem zufälligen Tag zuweisen
|
- api/ui: Türchen mit Tag "0" einem zufälligen Tag zuweisen
|
||||||
- api/?: Option "custom Zuordnung Buchstaben" (standard leer)
|
- api/?: Option "custom Zuordnung Buchstaben" (standard leer)
|
||||||
- api: `config.solution` - whitespace="IGNORE"->"REMOVE" umbenennen, +Sonderzeichen
|
|
||||||
- ui: `confirm` durch bulma Komponente(n) ersetzen
|
- ui: `confirm` durch bulma Komponente(n) ersetzen
|
||||||
|
|
||||||
# Erledigt
|
# Erledigt
|
||||||
|
@ -20,3 +19,4 @@
|
||||||
- Nach einigen Sekunden: Meldung "Türchen anzeigen?"
|
- Nach einigen Sekunden: Meldung "Türchen anzeigen?"
|
||||||
- `alert` durch bulma Komponente(n) ersetzen
|
- `alert` durch bulma Komponente(n) ersetzen
|
||||||
- api: admin Login case sensitivity (username "admin" == "AdMiN")
|
- api: admin Login case sensitivity (username "admin" == "AdMiN")
|
||||||
|
- api: `config.solution` - whitespace="IGNORE"->"REMOVE" umbenennen, +Sonderzeichen
|
||||||
|
|
|
@ -29,7 +29,12 @@ class TransformedString(BaseModel):
|
||||||
# whitespace entfernen
|
# whitespace entfernen
|
||||||
REMOVE = "REMOVE"
|
REMOVE = "REMOVE"
|
||||||
|
|
||||||
# special chars
|
class __SpecialChars(str, Enum):
|
||||||
|
# unverändert
|
||||||
|
KEEP = "KEEP"
|
||||||
|
|
||||||
|
# Sonderzeichen entfernen
|
||||||
|
REMOVE = "REMOVE"
|
||||||
|
|
||||||
class __Case(str, Enum):
|
class __Case(str, Enum):
|
||||||
# unverändert
|
# unverändert
|
||||||
|
@ -47,6 +52,7 @@ class TransformedString(BaseModel):
|
||||||
value: str
|
value: str
|
||||||
|
|
||||||
whitespace: __Whitespace = __Whitespace.REMOVE
|
whitespace: __Whitespace = __Whitespace.REMOVE
|
||||||
|
special_chars: __SpecialChars = __SpecialChars.REMOVE
|
||||||
case: __Case = __Case.UPPER
|
case: __Case = __Case.UPPER
|
||||||
|
|
||||||
@field_validator("whitespace", "case", mode="before")
|
@field_validator("whitespace", "case", mode="before")
|
||||||
|
@ -67,6 +73,10 @@ class TransformedString(BaseModel):
|
||||||
elif self.whitespace is TransformedString.__Whitespace.REMOVE:
|
elif self.whitespace is TransformedString.__Whitespace.REMOVE:
|
||||||
result = re.sub(string=result, pattern=r"\s+", repl="")
|
result = re.sub(string=result, pattern=r"\s+", repl="")
|
||||||
|
|
||||||
|
# Sonderzeichen verarbeiten
|
||||||
|
if self.special_chars is TransformedString.__SpecialChars.REMOVE:
|
||||||
|
result = re.sub(string=result, pattern=r"[^a-zA-Z0-9\s]+", repl="")
|
||||||
|
|
||||||
# Groß-/Kleinschreibung verarbeiten
|
# Groß-/Kleinschreibung verarbeiten
|
||||||
if self.case is TransformedString.__Case.UPPER:
|
if self.case is TransformedString.__Case.UPPER:
|
||||||
result = result.upper()
|
result = result.upper()
|
||||||
|
|
|
@ -31,6 +31,7 @@ class AdminConfigModel(BaseModel):
|
||||||
class __Solution(BaseModel):
|
class __Solution(BaseModel):
|
||||||
value: str
|
value: str
|
||||||
whitespace: str
|
whitespace: str
|
||||||
|
special_chars: str
|
||||||
case: str
|
case: str
|
||||||
clean: str
|
clean: str
|
||||||
|
|
||||||
|
@ -81,6 +82,7 @@ async def get_config_model(
|
||||||
"solution": {
|
"solution": {
|
||||||
"value": cfg.solution.value,
|
"value": cfg.solution.value,
|
||||||
"whitespace": cfg.solution.whitespace,
|
"whitespace": cfg.solution.whitespace,
|
||||||
|
"special_chars": cfg.solution.special_chars,
|
||||||
"case": cfg.solution.case,
|
"case": cfg.solution.case,
|
||||||
"clean": cfg.solution.clean,
|
"clean": cfg.solution.clean,
|
||||||
},
|
},
|
||||||
|
|
|
@ -27,6 +27,12 @@
|
||||||
{{ admin_config_model.solution.whitespace }}
|
{{ admin_config_model.solution.whitespace }}
|
||||||
</span>
|
</span>
|
||||||
</dd>
|
</dd>
|
||||||
|
<dd>
|
||||||
|
Sonderzeichen:
|
||||||
|
<span class="is-uppercase is-family-monospace">
|
||||||
|
{{ admin_config_model.solution.special_chars }}
|
||||||
|
</span>
|
||||||
|
</dd>
|
||||||
<dd>
|
<dd>
|
||||||
Buchstaben:
|
Buchstaben:
|
||||||
<span class="is-uppercase is-family-monospace">
|
<span class="is-uppercase is-family-monospace">
|
||||||
|
@ -184,6 +190,7 @@ export default class extends Vue {
|
||||||
solution: {
|
solution: {
|
||||||
value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||||
whitespace: "KEEP",
|
whitespace: "KEEP",
|
||||||
|
special_chars: "KEEP",
|
||||||
case: "KEEP",
|
case: "KEEP",
|
||||||
clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,6 +2,7 @@ export interface AdminConfigModel {
|
||||||
solution: {
|
solution: {
|
||||||
value: string;
|
value: string;
|
||||||
whitespace: string;
|
whitespace: string;
|
||||||
|
special_chars: string;
|
||||||
case: string;
|
case: string;
|
||||||
clean: string;
|
clean: string;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue