Skip to content

Commit

Permalink
Merge pull request #933 from pateljannat/issues-25
Browse files Browse the repository at this point in the history
fix: misc issues
  • Loading branch information
pateljannat authored Jul 17, 2024
2 parents 0183677 + 493bab8 commit e0de9d7
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 45 deletions.
15 changes: 5 additions & 10 deletions frontend/src/components/CourseCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,23 @@
<div
v-if="course.title"
class="flex flex-col h-full rounded-md shadow-md text-base overflow-auto"
style="min-height: 320px"
style="min-height: 350px"
>
<div
class="course-image"
:class="{ 'default-image': !course.image }"
:style="{ backgroundImage: 'url(\'' + encodeURI(course.image) + '\')' }"
>
<div class="flex relative top-4 left-4 w-fit flex-wrap">
<Badge
v-if="course.featured"
variant="subtle"
theme="green"
size="md"
class="mr-2"
>
<div
class="flex items-center flex-wrap space-y-1 space-x-1 relative top-4 px-2 w-fit"
>
<Badge v-if="course.featured" variant="subtle" theme="green" size="md">
{{ __('Featured') }}
</Badge>
<Badge
variant="outline"
theme="gray"
size="md"
class="mr-2"
v-for="tag in course.tags"
>
{{ tag }}
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/components/Modals/EvaluationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,14 @@ function submitEvaluation(close) {
close()
},
onError(err) {
let message = err.messages?.[0] || err
let unavailabilityMessage = message.includes('unavailable')
createToast({
title: 'Error',
text: err.messages?.[0] || err,
icon: 'x',
iconClasses: 'bg-red-600 text-white rounded-md p-px',
title: unavailabilityMessage ? 'Evaluator is Unavailable' : 'Error',
text: message,
icon: unavailabilityMessage ? 'alert-circle' : 'x',
iconClasses: 'bg-yellow-600 text-white rounded-md p-px',
position: 'top-center',
timeout: 10,
})
Expand Down
23 changes: 16 additions & 7 deletions frontend/src/pages/CertifiedParticipants.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
</header>

<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 m-5">
<div v-if="participants.data" v-for="participant in participants.data">
<div
v-if="participants.data?.length"
v-for="participant in participantsList"
>
<router-link
:to="{
name: 'Profile',
Expand Down Expand Up @@ -59,12 +62,7 @@ const searchQuery = ref('')
const participants = createResource({
url: 'lms.lms.api.get_certified_participants',
method: 'GET',
debounce: 300,
makeParams(values) {
return {
search_query: searchQuery.value,
}
},
cache: 'certified-participants',
auto: true,
})
Expand All @@ -79,5 +77,16 @@ const pageMeta = computed(() => {
}
})
const participantsList = computed(() => {
if (searchQuery.value) {
return participants.data.filter((participant) => {
return participant.full_name
.toLowerCase()
.includes(searchQuery.value.toLowerCase())
})
}
return participants.data
})
updateDocumentTitle(pageMeta)
</script>
13 changes: 8 additions & 5 deletions frontend/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,18 @@ export function getFileSize(file_size) {
return value
}

export function showToast(title, text, icon) {
export function showToast(title, text, icon, iconClasses = null) {
if (!iconClasses) {
iconClasses =
icon == 'check'
? 'bg-green-600 text-white rounded-md p-px'
: 'bg-red-600 text-white rounded-md p-px'
}
createToast({
title: title,
text: htmlToText(text),
icon: icon,
iconClasses:
icon == 'check'
? 'bg-green-600 text-white rounded-md p-px'
: 'bg-red-600 text-white rounded-md p-px',
iconClasses: iconClasses,
position: icon == 'check' ? 'bottom-right' : 'top-center',
timeout: 5,
})
Expand Down
3 changes: 1 addition & 2 deletions lms/lms/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,12 @@ def get_evaluator_details(evaluator):


@frappe.whitelist(allow_guest=True)
def get_certified_participants(search_query=""):
def get_certified_participants():
LMSCertificate = DocType("LMS Certificate")
participants = (
frappe.qb.from_(LMSCertificate)
.select(LMSCertificate.member)
.distinct()
.where(LMSCertificate.member_name.like(f"%{search_query}%"))
.where(LMSCertificate.published == 1)
.orderby(LMSCertificate.creation, order=frappe.qb.desc)
.run(as_dict=1)
Expand Down
28 changes: 14 additions & 14 deletions lms/lms/doctype/lms_certificate/lms_certificate.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
"field_order": [
"course",
"course_title",
"column_break_3",
"member",
"member_name",
"published",
"section_break_tnnm",
"template",
"batch_name",
"column_break_qtzo",
"column_break_vwbn",
"issue_date",
"expiry_date"
"template",
"published",
"section_break_scyf",
"expiry_date",
"column_break_slaw",
"batch_name"
],
"fields": [
{
Expand All @@ -27,10 +27,6 @@
"label": "Issue Date",
"reqd": 1
},
{
"fieldname": "column_break_3",
"fieldtype": "Column Break"
},
{
"fieldname": "course",
"fieldtype": "Link",
Expand Down Expand Up @@ -89,17 +85,21 @@
"read_only": 1
},
{
"fieldname": "section_break_tnnm",
"fieldname": "column_break_vwbn",
"fieldtype": "Column Break"
},
{
"fieldname": "section_break_scyf",
"fieldtype": "Section Break"
},
{
"fieldname": "column_break_qtzo",
"fieldname": "column_break_slaw",
"fieldtype": "Column Break"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-07-12 12:39:50.076937",
"modified": "2024-07-16 15:29:19.708888",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"fieldtype": "Rating",
"in_list_view": 1,
"label": "Rating",
"mandatory_depends_on": "eval:doc.status != 'Pending' && doc.status != 'In Progress'"
"mandatory_depends_on": "eval:doc.status == 'Pass'"
},
{
"fieldname": "summary",
Expand Down Expand Up @@ -107,7 +107,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-04-15 11:22:43.189908",
"modified": "2024-07-16 14:06:11.977666",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate Evaluation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def validate_unavailability(self):
):
frappe.throw(
_(
"Evaluator is unavailable from {0} to {1}. Please select a date after {1}"
"The evaluator of this course is unavailable from {0} to {1}. Please select a date after {1}"
).format(
format_date(unavailable.unavailable_from, "medium"),
format_date(unavailable.unavailable_to, "medium"),
Expand Down

0 comments on commit e0de9d7

Please sign in to comment.