Skip to content

Commit

Permalink
Merge pull request #1013 from frappe/develop
Browse files Browse the repository at this point in the history
chore: merge 'develop' into 'main'
  • Loading branch information
pateljannat authored Sep 11, 2024
2 parents 0fd1cab + 237ff8d commit de8c907
Show file tree
Hide file tree
Showing 16 changed files with 200 additions and 175 deletions.
132 changes: 76 additions & 56 deletions frontend/src/components/Members.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<div class="text-base p-4">
<div class="flex min-h-0 flex-col text-base">
<div class="flex items-center justify-between">
<div>
<div class="font-semibold mb-1">
<div class="text-xl font-semibold mb-1">
{{ __(label) }}
</div>
<div class="text-xs text-gray-600">
<!-- <div class="text-xs text-gray-600">
{{ __(description) }}
</div>
</div> -->
</div>
<div class="flex item-center space-x-2">
<FormControl
Expand All @@ -16,74 +16,93 @@
type="text"
:debounce="300"
/>
<Button @click="() => (showForm = true)">
<Button @click="() => (showForm = !showForm)">
<template #icon>
<Plus class="h-3 w-3 stroke-1.5" />
<Plus v-if="!showForm" class="h-3 w-3 stroke-1.5" />
<X v-else class="h-3 w-3 stroke-1.5" />
</template>
</Button>
</div>
</div>
<div class="my-4">
<!-- Form to add new member -->
<div v-if="showForm" class="flex items-center space-x-2 mb-4">
<FormControl
v-model="member.email"
:placeholder="__('Email')"
type="email"
class="w-full"
/>
<FormControl
v-model="member.first_name"
:placeholder="__('First Name')"
type="test"
class="w-full"
/>
<Button @click="addMember()" variant="subtle">
{{ __('Add') }}
</Button>
</div>

<!-- Form to add new member -->
<div v-if="showForm" class="flex items-center space-x-2 my-4">
<FormControl
v-model="member.email"
:placeholder="__('Email')"
type="email"
class="w-full"
/>
<FormControl
v-model="member.first_name"
:placeholder="__('First Name')"
type="test"
class="w-full"
/>
<Button @click="addMember()" variant="subtle">
{{ __('Add') }}
</Button>
</div>

<div class="mt-2 pb-10 overflow-auto">
<!-- Member list -->
<div class="overflow-y-scroll">
<ul class="divide-y">
<li
v-for="member in memberList"
class="grid grid-cols-3 gap-10 py-2 cursor-pointer"
>
<div
@click="openProfile(member.username)"
class="flex items-center space-x-3 col-span-2"
>
<Avatar
:image="member.user_image"
:label="member.full_name"
size="lg"
/>
<div class="space-y-1">
<div class="flex">
<div class="text-gray-900">
{{ member.full_name }}
</div>
<div v-if="getRole(member)">
{{ getRole(member) }}
</div>
</div>
<div class="text-sm text-gray-700">
{{ member.name }}
</div>
</div>
</div>
<div class="flex items-center justify-center text-gray-700 text-sm">
<div v-if="member.last_active">
{{ dayjs(member.last_active).format('DD MMM, YYYY HH:mm a') }}
</div>
<div v-else>-</div>
</div>
</li>
</ul>
</div>
<div
v-for="member in memberList"
class="grid grid-cols-5 grid-flow-row py-2 cursor-pointer"
v-if="memberList.length && hasNextPage"
class="flex justify-center mt-4"
>
<div
@click="openProfile(member.username)"
class="flex items-center space-x-2 col-span-2"
>
<Avatar
:image="member.user_image"
:label="member.full_name"
size="sm"
/>
<div>
{{ member.full_name }}
</div>
</div>
<div class="text-sm text-gray-700 col-span-2">
{{ member.name }}
</div>
<div class="text-sm text-gray-700 justify-self-end">
{{ getRole(member.role) }}
</div>
<Button @click="members.reload()">
<template #prefix>
<RefreshCw class="h-3 w-3 stroke-1.5" />
</template>
{{ __('Load More') }}
</Button>
</div>
</div>
<div v-if="hasNextPage" class="flex justify-center">
<Button variant="solid" @click="members.reload()">
<template #prefix>
<RefreshCw class="h-3 w-3 stroke-1.5" />
</template>
{{ __('Load More') }}
</Button>
</div>
</div>
</template>
<script setup lang="ts">
import { createResource, Avatar, Button, FormControl } from 'frappe-ui'
import { useRouter } from 'vue-router'
import { ref, watch, reactive } from 'vue'
import { RefreshCw, Plus } from 'lucide-vue-next'
import { ref, watch, reactive, inject } from 'vue'
import { RefreshCw, Plus, X } from 'lucide-vue-next'
const router = useRouter()
const show = defineModel('show')
Expand All @@ -92,6 +111,7 @@ const start = ref(0)
const memberList = ref([])
const hasNextPage = ref(false)
const showForm = ref(false)
const dayjs = inject('$dayjs')
const member = reactive({
email: '',
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/Modals/Settings.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<Dialog v-model="show" :options="{ size: '3xl' }">
<Dialog v-model="show" :options="{ size: '4xl' }">
<template #body>
<div class="flex h-[calc(100vh_-_8rem)]">
<div class="flex w-52 shrink-0 flex-col bg-gray-50 p-2">
Expand Down Expand Up @@ -30,7 +30,7 @@
</div>
<div
v-if="activeTab && data.doc"
class="flex flex-1 flex-col overflow-y-auto"
class="flex flex-1 flex-col px-10 pt-8"
>
<Members
v-if="activeTab.label === 'Members'"
Expand Down Expand Up @@ -131,7 +131,7 @@ const tabs = computed(() => {
{
label: 'Sidebar',
icon: 'PanelLeftIcon',
description: 'Customize the sidebar as per your needs',
description: 'Choose the items you want to show in the sidebar',
fields: [
{
label: 'Courses',
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/SettingDetails.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="flex flex-col justify-between h-full p-4">
<div class="flex flex-col justify-between h-full">
<div>
<div class="font-semibold mb-1">
{{ __(label) }}
Expand All @@ -8,9 +8,9 @@
{{ __(description) }}
</div>
</div>
<div class="flex space-x-8 my-5">
<div class="flex justify-between my-5">
<div v-for="(column, index) in columns" :key="index">
<div class="flex flex-col space-y-4 w-60">
<div class="flex flex-col space-y-5 w-72">
<div v-for="field in column">
<Link
v-if="field.type == 'Link'"
Expand Down
2 changes: 1 addition & 1 deletion lms/lms/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def get_members(start=0, search=""):
members = frappe.get_all(
"User",
filters=filters,
fields=["name", "full_name", "user_image", "username"],
fields=["name", "full_name", "user_image", "username", "last_active"],
page_length=20,
start=start,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@
"engine": "InnoDB",
"field_order": [
"course",
"evaluator",
"batch_name",
"course_title",
"column_break_4",
"member",
"member_name",
"section_break_ikne",
"evaluator",
"evaluator_name",
"column_break_sjco",
"batch_name",
"timezone",
"section_break_lifi",
"date",
"day",
Expand Down Expand Up @@ -103,11 +108,40 @@
"in_standard_filter": 1,
"label": "Batch",
"options": "LMS Batch"
},
{
"fieldname": "section_break_ikne",
"fieldtype": "Section Break"
},
{
"fieldname": "column_break_sjco",
"fieldtype": "Column Break"
},
{
"fetch_from": "course.title",
"fieldname": "course_title",
"fieldtype": "Data",
"label": "Course Title",
"read_only": 1
},
{
"fetch_from": "evaluator.full_name",
"fieldname": "evaluator_name",
"fieldtype": "Data",
"label": "Evaluator Name",
"read_only": 1
},
{
"fetch_from": "batch_name.timezone",
"fieldname": "timezone",
"fieldtype": "Data",
"label": "Timezone",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-04-16 11:01:28.336807",
"modified": "2024-09-05 16:28:54.043488",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate Request",
Expand Down
44 changes: 23 additions & 21 deletions lms/lms/doctype/lms_certificate_request/lms_certificate_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,27 @@ def set_evaluator(self):
self.evaluator = get_evaluator(self.course, self.batch_name)

def validate_unavailability(self):
unavailable = frappe.db.get_value(
"Course Evaluator", self.evaluator, ["unavailable_from", "unavailable_to"], as_dict=1
)
if (
unavailable.unavailable_from
and unavailable.unavailable_to
and getdate(self.date) >= unavailable.unavailable_from
and getdate(self.date) <= unavailable.unavailable_to
):
frappe.throw(
_(
"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"),
)
if self.evaluator:
unavailable = frappe.db.get_value(
"Course Evaluator",
self.evaluator,
["unavailable_from", "unavailable_to"],
as_dict=1,
)
if (
unavailable.unavailable_from
and unavailable.unavailable_to
and getdate(self.date) >= unavailable.unavailable_from
and getdate(self.date) <= unavailable.unavailable_to
):
frappe.throw(
_(
"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"),
)
)

def validate_slot(self):
if frappe.db.exists(
Expand Down Expand Up @@ -120,14 +124,12 @@ def send_notification(self):
template = "certificate_request_notification"

args = {
"course": frappe.db.get_value("LMS Course", self.course, "title"),
"timezone": frappe.db.get_value("LMS Batch", self.batch_name, "timezone")
if self.batch_name
else "",
"course": self.course_title,
"timezone": self.timezone if self.batch_name else "",
"date": format_date(self.date, "medium"),
"member_name": self.member_name,
"start_time": format_time(self.start_time, "short"),
"evaluator": frappe.db.get_value("User", self.evaluator, "full_name"),
"evaluator": self.evaluator_name,
}

frappe.sendmail(
Expand Down
Empty file.

This file was deleted.

This file was deleted.

Loading

0 comments on commit de8c907

Please sign in to comment.