fix: validation for URL
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from frappe.utils import validate_url
|
||||||
|
|
||||||
|
|
||||||
class LMSAssignmentSubmission(Document):
|
class LMSAssignmentSubmission(Document):
|
||||||
@@ -40,9 +41,13 @@ def upload_assignment(
|
|||||||
|
|
||||||
if assignment_type == "URL" and not answer:
|
if assignment_type == "URL" and not answer:
|
||||||
frappe.throw(_("Please enter the URL for assignment submission."))
|
frappe.throw(_("Please enter the URL for assignment submission."))
|
||||||
|
|
||||||
if assignment_type == "File" and not assignment_attachment:
|
if assignment_type == "File" and not assignment_attachment:
|
||||||
frappe.throw(_("Please upload the assignment file."))
|
frappe.throw(_("Please upload the assignment file."))
|
||||||
|
|
||||||
|
if assignment_type == "URL" and not validate_url(answer):
|
||||||
|
frappe.throw(_("Please enter a valid URL."))
|
||||||
|
|
||||||
if submission:
|
if submission:
|
||||||
doc = frappe.get_doc("LMS Assignment Submission", submission)
|
doc = frappe.get_doc("LMS Assignment Submission", submission)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ submission }}
|
|
||||||
<div class="field-group">
|
<div class="field-group">
|
||||||
<div class="bold-heading">
|
<div class="bold-heading">
|
||||||
{{ _("Submit")}}
|
{{ _("Submit")}}
|
||||||
|
|||||||
Reference in New Issue
Block a user