feat: show notifications from logs
This commit is contained in:
@@ -74,7 +74,7 @@
|
||||
|
||||
<!-- Edit Button -->
|
||||
{% if (is_instructor or has_course_moderator_role()) and not lesson.edit_mode %}
|
||||
<button class="button is-default button-links ml-auto btn-edit"> {{ _("Edit") }} </button>
|
||||
<button class="button is-default button-links ml-2 btn-edit"> {{ _("Edit") }} </button>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ def get_context(context):
|
||||
context.chapter = frappe.db.get_value("Chapter Reference", {
|
||||
"idx": chapter_index,
|
||||
"parent": context.course.name
|
||||
}, "chapter")
|
||||
}, "chapter")
|
||||
|
||||
if not chapter_index or not lesson_index:
|
||||
if context.batch:
|
||||
|
||||
@@ -347,7 +347,7 @@
|
||||
{% endif %}
|
||||
|
||||
{% if is_instructor(course.name) or has_course_moderator_role() %}
|
||||
<a class="btn btn-secondary wide-button" href="/courses/{{ course.name }}?edit=1"> {{ _("Edit Course") }} </a>
|
||||
<a class="btn btn-secondary wide-button mt-3" href="/courses/{{ course.name }}?edit=1"> {{ _("Edit Course") }} </a>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
<ul class="nav lms-nav" id="courses-tab">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#courses-enrolled">
|
||||
{{ _("Courses Enrolled") }}
|
||||
{{ _("Enrolled") }}
|
||||
</a>
|
||||
</li>
|
||||
|
||||
{% if show_creators_section %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-created">
|
||||
{{ _("Courses Created") }}
|
||||
{{ _("Created") }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
@@ -32,7 +32,7 @@
|
||||
{% if show_review_section %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#courses-under-review">
|
||||
{{ _("Courses Under Review") }}
|
||||
{{ _("Under Review") }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
@@ -61,20 +61,8 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="tab-pane fade" id="notifications" role="tabpanel" aria-labelledby="notifications">
|
||||
{% if notifications | length %}
|
||||
{% for notification in notifications %}
|
||||
{{ notification }}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<img class="icon icon-xl" src="/assets/lms/icons/comment.svg">
|
||||
<div class="empty-state-text">
|
||||
<div class="empty-state-heading">{{ _("No Notifications") }}</div>
|
||||
<div class="course-meta">{{ _("You don't have any notifications.") }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="tab-pane" id="notifications" role="tabpanel" aria-labelledby="notifications">
|
||||
{% include "lms/templates/notifications.html" %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import frappe
|
||||
from datetime import datetime
|
||||
from lms.lms.utils import has_course_instructor_role, has_course_moderator_role
|
||||
from lms.lms.utils import has_course_instructor_role, has_course_moderator_role, get_lesson_index
|
||||
|
||||
|
||||
def get_context(context):
|
||||
@@ -12,6 +12,19 @@ def get_context(context):
|
||||
|
||||
|
||||
def get_notifications():
|
||||
notifications = frappe.get_all("Notification Log", {
|
||||
"document_type": "Course Lesson",
|
||||
"for_user": frappe.session.user
|
||||
}, ["subject", "creation", "from_user", "document_name"])
|
||||
|
||||
for notification in notifications:
|
||||
course = frappe.db.get_value("Course Lesson", notification.document_name, "course")
|
||||
notification.url = "/courses/{0}/learn/{1}".format(course, get_lesson_index(notification.document_name))
|
||||
|
||||
return notifications
|
||||
|
||||
|
||||
def get_notifications_old():
|
||||
notifications = []
|
||||
|
||||
notifications += get_notifications_from_lessons_created()
|
||||
@@ -19,7 +32,6 @@ def get_notifications():
|
||||
notifications += get_notifications_from_topics_created()
|
||||
|
||||
if len(notifications):
|
||||
print(notifications)
|
||||
notifications = sorted(notifications, key=lambda t: datetime.strptime(frappe.utils.format_datetime(t.creation, "dd-mm-yyyy HH:mm:ss"),"%d/%m/%Y %H:%M:%S"))
|
||||
return notifications
|
||||
|
||||
@@ -57,7 +69,6 @@ def get_notifications_from_replies(topics):
|
||||
"topic": topic.name
|
||||
}, ["reply", "owner", "creation"])
|
||||
|
||||
|
||||
for reply in replies:
|
||||
notification = frappe._dict()
|
||||
notification["message"] = reply.reply
|
||||
|
||||
Reference in New Issue
Block a user