[WEB-1933] refactor: link create/update for issues and modules (#5543)
* chore: added module and issue link validation * refactor: issues and modules link moda; * chore: changed the url validation logic * chore: code cleanup * refactor: modules link logic * chore: removed the validator function * fix: url validation regex * chore: removed unwanted imports * chore: reverted the external api changes * refactor: link modals * refactor: reset modal logic --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
This commit is contained in:
parent
c95aa6a0f7
commit
68b412badf
16 changed files with 497 additions and 475 deletions
|
|
@ -437,17 +437,21 @@ class IssueLinkSerializer(BaseSerializer):
|
|||
"issue",
|
||||
]
|
||||
|
||||
def validate_url(self, value):
|
||||
# Check URL format
|
||||
validate_url = URLValidator()
|
||||
try:
|
||||
validate_url(value)
|
||||
except ValidationError:
|
||||
raise serializers.ValidationError("Invalid URL format.")
|
||||
def to_internal_value(self, data):
|
||||
# Modify the URL before validation by appending http:// if missing
|
||||
url = data.get("url", "")
|
||||
if url and not url.startswith(("http://", "https://")):
|
||||
data["url"] = "http://" + url
|
||||
|
||||
# Check URL scheme
|
||||
if not value.startswith(("http://", "https://")):
|
||||
raise serializers.ValidationError("Invalid URL scheme.")
|
||||
return super().to_internal_value(data)
|
||||
|
||||
def validate_url(self, value):
|
||||
# Use Django's built-in URLValidator for validation
|
||||
url_validator = URLValidator()
|
||||
try:
|
||||
url_validator(value)
|
||||
except ValidationError:
|
||||
raise serializers.ValidationError({"error": "Invalid URL format."})
|
||||
|
||||
return value
|
||||
|
||||
|
|
@ -533,7 +537,7 @@ class IssueReactionSerializer(BaseSerializer):
|
|||
"project",
|
||||
"issue",
|
||||
"actor",
|
||||
"deleted_at"
|
||||
"deleted_at",
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -552,7 +556,13 @@ class CommentReactionSerializer(BaseSerializer):
|
|||
class Meta:
|
||||
model = CommentReaction
|
||||
fields = "__all__"
|
||||
read_only_fields = ["workspace", "project", "comment", "actor", "deleted_at"]
|
||||
read_only_fields = [
|
||||
"workspace",
|
||||
"project",
|
||||
"comment",
|
||||
"actor",
|
||||
"deleted_at",
|
||||
]
|
||||
|
||||
|
||||
class IssueVoteSerializer(BaseSerializer):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue