Merge pull request #1256 from pateljannat/issues-68
fix: changed the naming for certificate and job opportunity
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
frappe.ui.form.on("Job Opportunity", {
|
||||
refresh: (frm) => {
|
||||
if (frm.doc.name)
|
||||
frm.add_web_link(`/job-openings/${frm.doc.name}`, "See on Website");
|
||||
frm.add_web_link(
|
||||
`/lms/job-openings/${frm.doc.name}`,
|
||||
"See on Website"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
"actions": [],
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "format: JOB-{#####}",
|
||||
"creation": "2022-02-07 12:01:41.074418",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
@@ -117,11 +116,10 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"make_attachments_public": 1,
|
||||
"modified": "2024-02-07 23:02:06.102120",
|
||||
"modified": "2025-01-17 12:38:57.134919",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Job",
|
||||
"name": "Job Opportunity",
|
||||
"naming_rule": "Expression",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
|
||||
@@ -6,8 +6,7 @@ from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import get_link_to_form, add_months, getdate
|
||||
from frappe.utils.user import get_system_managers
|
||||
|
||||
from lms.lms.utils import validate_image
|
||||
from lms.lms.utils import validate_image, generate_slug
|
||||
|
||||
|
||||
class JobOpportunity(Document):
|
||||
@@ -18,6 +17,10 @@ class JobOpportunity(Document):
|
||||
def validate_urls(self):
|
||||
frappe.utils.validate_url(self.company_website, True)
|
||||
|
||||
def autoname(self):
|
||||
if not self.name:
|
||||
self.name = generate_slug(f"{self.job_title}-${self.company_name}", "LMS Course")
|
||||
|
||||
|
||||
def update_job_openings():
|
||||
old_jobs = frappe.get_all(
|
||||
|
||||
@@ -72,9 +72,12 @@ class LMSAssignmentSubmission(Document):
|
||||
)
|
||||
|
||||
def validate_status(self):
|
||||
doc_before_save = self.get_doc_before_save()
|
||||
if doc_before_save.status != self.status or doc_before_save.comments != self.comments:
|
||||
self.trigger_update_notification()
|
||||
if not self.is_new():
|
||||
doc_before_save = self.get_doc_before_save()
|
||||
if (
|
||||
doc_before_save.status != self.status or doc_before_save.comments != self.comments
|
||||
):
|
||||
self.trigger_update_notification()
|
||||
|
||||
def trigger_update_notification(self):
|
||||
notification = frappe._dict(
|
||||
|
||||
@@ -48,7 +48,10 @@ frappe.ui.form.on("LMS Batch", {
|
||||
},
|
||||
|
||||
refresh: (frm) => {
|
||||
frm.add_web_link(`/batches/details/${frm.doc.name}`, "See on website");
|
||||
frm.add_web_link(
|
||||
`/lms/batches/details/${frm.doc.name}`,
|
||||
"See on website"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_import": 1,
|
||||
"autoname": "hash",
|
||||
"creation": "2021-08-16 15:47:19.494055",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
@@ -123,11 +122,10 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2025-01-16 12:12:49.998114",
|
||||
"modified": "2025-01-17 11:57:02.859109",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Certificate",
|
||||
"naming_rule": "Random",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
|
||||
@@ -7,12 +7,16 @@ from frappe.model.document import Document
|
||||
from frappe.utils import add_years, nowdate
|
||||
from lms.lms.utils import is_certified
|
||||
from frappe.email.doctype.email_template.email_template import get_email_template
|
||||
from frappe.model.naming import make_autoname
|
||||
|
||||
|
||||
class LMSCertificate(Document):
|
||||
def validate(self):
|
||||
self.validate_duplicate_certificate()
|
||||
|
||||
def autoname(self):
|
||||
self.name = make_autoname("hash", self.doctype)
|
||||
|
||||
def after_insert(self):
|
||||
if not frappe.flags.in_test:
|
||||
outgoing_email_account = frappe.get_cached_value(
|
||||
@@ -48,16 +52,46 @@ class LMSCertificate(Document):
|
||||
)
|
||||
|
||||
def validate_duplicate_certificate(self):
|
||||
certificates = frappe.get_all(
|
||||
"LMS Certificate",
|
||||
{"member": self.member, "course": self.course, "name": ["!=", self.name]},
|
||||
)
|
||||
if len(certificates):
|
||||
full_name = frappe.db.get_value("User", self.member, "full_name")
|
||||
course_name = frappe.db.get_value("LMS Course", self.course, "title")
|
||||
frappe.throw(
|
||||
_("{0} is already certified for the course {1}").format(full_name, course_name)
|
||||
self.validate_course_duplicates()
|
||||
self.validate_batch_duplicates()
|
||||
|
||||
def validate_course_duplicates(self):
|
||||
if self.course:
|
||||
course_duplicates = frappe.get_all(
|
||||
"LMS Certificate",
|
||||
filters={
|
||||
"member": self.member,
|
||||
"name": ["!=", self.name],
|
||||
"course": self.course,
|
||||
},
|
||||
fields=["name", "course", "course_title"],
|
||||
)
|
||||
if len(course_duplicates):
|
||||
full_name = frappe.db.get_value("User", self.member, "full_name")
|
||||
frappe.throw(
|
||||
_("{0} is already certified for the course {1}").format(
|
||||
full_name, course_duplicates[0].course_title
|
||||
)
|
||||
)
|
||||
|
||||
def validate_batch_duplicates(self):
|
||||
if self.batch_name:
|
||||
batch_duplicates = frappe.get_all(
|
||||
"LMS Certificate",
|
||||
filters={
|
||||
"member": self.member,
|
||||
"name": ["!=", self.name],
|
||||
"batch_name": self.batch_name,
|
||||
},
|
||||
fields=["name", "batch_name", "batch_title"],
|
||||
)
|
||||
if len(batch_duplicates):
|
||||
full_name = frappe.db.get_value("User", self.member, "full_name")
|
||||
frappe.throw(
|
||||
_("{0} is already certified for the batch {1}").format(
|
||||
full_name, batch_duplicates[0].batch_title
|
||||
)
|
||||
)
|
||||
|
||||
def on_update(self):
|
||||
frappe.share.add_docshare(
|
||||
|
||||
Reference in New Issue
Block a user