Skip to content

Commit

Permalink
naprawiony błąd braku zwrotu informacji o walidacji. Dodane logowanie.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivellios committed Dec 16, 2024
1 parent 6adf469 commit a98255f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .github/scripts/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import logging
import os

import yaml
from github import Auth, Github, Issue

from consts import OrgSchemaIds, NEW_ORG_ISSUE_DEFAULT_TITLE, NEW_ORG_SCHEMA_FILENAME
from labels import Label, INVALID_FIELD_TO_LABEL
from labels import Label
from parsers import FormDataParser
from pullers import OrgDataPuller
from utils import has_label
Expand All @@ -29,9 +28,11 @@ def process_new_org_issue(issue: Issue, data: FormDataParser):

validator = OrgValidator(data, issue)
if not validator.validate():
logger.error("Validation failed")
return

if not (org := OrgDataPuller.get_org_by_krs(issue, data.get(OrgSchemaIds.krs))):
logger.error("KRS db validation failed")
return

# Update issue title
Expand All @@ -40,6 +41,7 @@ def process_new_org_issue(issue: Issue, data: FormDataParser):
issue.edit(title=f"{NEW_ORG_ISSUE_DEFAULT_TITLE} {org.name or data.get(OrgSchemaIds.name)}")

if not has_label(issue, Label.AUTO_VERIFIED):
logger.info("Adding auto-verified label")
issue.create_comment(f"@{issue.user.login}, dziękujemy za podanie informacji. "
f"Przyjęliśmy zgłoszenie dodania nowej organizacji. "
f"Wkrótce skontaktujemy się celem weryfikacji zgłoszenia.")
Expand Down
7 changes: 5 additions & 2 deletions .github/scripts/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from github import Issue

from consts import OrgSchemaIds, ORG_SCHEMA_SLUG_FIELD
from labels import INVALID_FIELD_TO_LABEL, Label
from labels import INVALID_FIELD_TO_LABEL
from parsers import FormDataParser
from utils import has_label

Expand Down Expand Up @@ -47,7 +47,7 @@ def validate_slug(self) -> tuple[bool, str]:

return True, ""

def validate(self) -> dict[str, bool]:
def validate(self) -> bool:
"""
Validates the organization data.
Expand Down Expand Up @@ -78,3 +78,6 @@ def validate(self) -> dict[str, bool]:
for field, error in errors:
msg += f"- **{self.data.get_label(field)}**: {error}\n"
self.issue.create_comment(msg)
return False

return True

0 comments on commit a98255f

Please sign in to comment.