fix: conflicts

This commit is contained in:
pateljannat
2021-05-07 12:08:51 +05:30
34 changed files with 514 additions and 319 deletions

View File

@@ -9,19 +9,16 @@
{% endblock %}
{% block content %}
{{ Sidebar(course_slug, batch_code) }}
{{ Sidebar(course.name, batch.name) }}
<div class="container">
{{ CourseBasicDetail(course)}}
{{ InstructorsSection(instructor) }}
{% if batch.description %}
{{ BatchDetails(batch.description) }}
{% endif %}
{{ MentorsSection(mentors, True, course.name) }}
{{ InstructorsSection(course.get_instructor()) }}
{{ BatchDetails(batch)}}
</div>
{% endblock %}
{% macro CourseBasicDetail(course) %}
<h2>{{course.name}}</h2>
<h2>{{course.title}}</h2>
<div class="course-description">
{{course.short_introduction}}
</div>
@@ -36,11 +33,25 @@
<div>{{frappe.utils.md_to_html(course.description)}}</div>
{% endmacro %}
{% macro BatchDetails(description) %}
<div class="mt-5">
<h3>About the Batch</h3>
<div>
{{ frappe.utils.md_to_html(description) }}
</div>
{% macro BatchDetails(batch) %}
<h2>About the Batch</h2>
<div class="batch">
<div class="batch-details">
<div>Session every {{batch.sessions_on}}</div>
<div>{{frappe.utils.format_time(batch.start_time, "short")}} -
{{frappe.utils.format_time(batch.end_time, "short")}}</div>
<div>Starting {{frappe.utils.format_date(batch.start_date, "medium")}}</div>
<div class="course-type" style="color: #888; padding: 10px 0px;">mentors</div>
{% for m in batch.get_mentors() %}
<div>
{% if m.photo_url %}
<img class="profile-photo" src="{{m.photo_url}}">
{% endif %}
<span class="instructor-title">{{m.full_name}}</span>
</div>
{% endfor %}
</div>
</div>
{% endmacro %}

View File

@@ -1,21 +1,21 @@
import frappe
from community.www.courses.utils import redirect_if_not_a_member, get_course, get_instructor, get_batch
from community.lms.models import Course
def get_context(context):
context.no_cache = 1
context.course_slug = frappe.form_dict["course"]
context.course = get_course(context.course_slug)
context.batch_code = frappe.form_dict["batch"]
redirect_if_not_a_member(context.course_slug, context.batch_code)
context.instructor = get_instructor(context.course.owner)
context.batch = get_batch(context.batch_code)
context.mentors = get_mentors(context.batch.name)
course_name = frappe.form_dict["course"]
batch_name = frappe.form_dict["batch"]
def get_mentors(batch):
mentors = []
memberships = frappe.get_all("LMS Batch Membership", {"batch": batch, "member_type": "Mentor"}, ["member"])
for membership in memberships:
member = frappe.get_doc("Community Member", membership.member)
mentors.append(member)
return mentors
course = Course.find(course_name)
if not course:
context.template = "www/404.html"
return
batch = course.get_batch(batch_name)
if not batch:
frappe.local.flags.redirect_location = "/courses/" + course_name
raise frappe.Redirect
context.course = course
context.batch = batch

View File

@@ -11,22 +11,23 @@
<div class="course-header">
<div class="course-type">course</div>
<h1 id="course-title" data-course="{{course.name}}">{{course.title}}</h1>
<div class="course-short-intro">{{ course.short_introduction }}</div>
</div>
<div class="row">
<div class="col-lg-9 col-md-12">
<div class="col-lg-8 col-md-12">
<div class="course-details">
{{ CourseVideo(course) }}
{{ CourseDescription(course) }}
{{ BatchSection(course) }}
{{ CourseOutline(course) }}
</div>
</div>
<div class="col-lg-3 col-md-12">
<div class="col-lg-4 col-md-12">
<div class="sidebar">
{{ InstructorsSection(course.get_instructor()) }}
</div>
<div class="sidebar">
{{ MentorsSection(course.get_mentors(), course.is_mentor(frappe.session.user), course.name) }}
</div>
@@ -35,14 +36,7 @@
</div>
{% endblock %}
{% macro CourseDescription(course) %}
<h2>Course Description</h2>
<div class="course-description">
{{ course.short_introduction }}
</div>
{% macro CourseVideo(course) %}
{% if course.video_link %}
<div class="preview-video">
<iframe
@@ -57,6 +51,14 @@
{% endif %}
{% endmacro %}
{% macro CourseDescription(course) %}
<h2>Course Description</h2>
<div class="course-description">
{{ course.short_introduction }}
</div>
{% endmacro %}
{% macro BatchSection(course) %}
{% if course.is_mentor(frappe.session.user) %}
{{ BatchSectionForMentors(course, course.get_batches(mentor=frappe.session.user)) }}
@@ -76,9 +78,7 @@
{% for m in batch.get_mentors() %}
<div>
{% if m.photo_url %}
<img class="profile-photo" src="{{m.photo_url}}">
{% endif %}
{{ widgets.Avatar(member=m, avatar_class="avatar-medium" ) }}
<span class="instructor-title">{{m.full_name}}</span>
</div>
{% endfor %}
@@ -86,7 +86,7 @@
<div class="cta">
<div class="">
{% if can_manage %}
<button >Manage</button>
<a href="/courses/{{course.name}}/{{batch.name}}/about" class="btn btn-secondary">Manage</a>
{% else %}
<button class="join-batch" data-batch="{{ batch.name | urlencode }}">Join this Batch</button>
{% endif %}
@@ -99,7 +99,7 @@
<h2>Your Batches</h2>
{% if mentor_batches %}
<div class="message">
<div class="alert alert-secondary">
You are a mentor for this course. Manage your batches or create a new batch from here.
</div>
@@ -136,6 +136,6 @@
<h2>Course Outline</h2>
{% for chapter in course.get_chapters() %}
{{ widgets.ChapterTeaser(chapter=chapter)}}
{{ widgets.ChapterTeaser(index=loop.index, chapter=chapter)}}
{% endfor %}
{% endmacro %}

View File

@@ -6,7 +6,7 @@ frappe.ready(() => {
course: decodeURIComponent($("#course-title").attr("data-course")),
},
'callback': (data) => {
if (data.message) {
if (data.message > 0) {
$("#mentor-request").addClass("hide");
$("#already-applied").removeClass("hide")
}

View File

@@ -7,12 +7,12 @@ def get_context(context):
context.no_cache = 1
try:
course_slug = frappe.form_dict["course"]
course_name = frappe.form_dict["course"]
except KeyError:
frappe.local.flags.redirect_location = "/courses"
raise frappe.Redirect
course = Course.find(course_slug)
course = Course.find(course_name)
if course is None:
frappe.local.flags.redirect_location = "/courses"
raise frappe.Redirect

View File

@@ -26,11 +26,11 @@
{% macro course_card(course) %}
<div class="card mb-5 w-100">
<div class="card-body">
<h5 class="card-title"><a href="/courses/{{course.slug}}">{{course.title}}</a></h5>
<h5 class="card-title"><a href="/courses/{{course.name}}">{{course.title}}</a></h5>
{% if course.description %}
<p class="card-text">{{ frappe.utils.md_to_html(course.description[:250]) }}</p>
{% endif %}
<a href="/courses/{{course.slug}}" class="card-link">See more &rarr;</a>
<a href="/courses/{{course.name}}" class="card-link">See more &rarr;</a>
</div>
</div>
{% endmacro %}

View File

@@ -7,7 +7,7 @@
{% endblock %}
{% block content %}
{{ Sidebar(course, batch_code) }}
{{ Sidebar(course.name, batch.name) }}
<div class="container">
</div>
{% endblock %}

View File

@@ -1,8 +1,21 @@
import frappe
from community.www.courses.utils import redirect_if_not_a_member
from community.lms.models import Course
def get_context(context):
context.no_cache = 1
context.course = frappe.form_dict["course"]
context.batch_code = frappe.form_dict["batch"]
redirect_if_not_a_member(context.course, context.batch_code)
course_name = frappe.form_dict["course"]
batch_name = frappe.form_dict["batch"]
course = Course.find(course_name)
if not course:
context.template = "www/404.html"
return
batch = course.get_batch(batch_name)
if not batch:
frappe.local.flags.redirect_location = "/courses/" + course_name
raise frappe.Redirect
context.course = course
context.batch = batch

View File

@@ -14,12 +14,14 @@ def get_member_with_name(name):
def get_batch(code):
try:
return frappe.db.get_value("LMS Batch", {"code": code}, ["name", "description"], as_dict=True)
print("get_batch", code)
return frappe.db.get_value("LMS Batch", {"name": code}, ["name", "description"], as_dict=True)
except frappe.DoesNotExistError:
print("Error: notfound")
return
def is_member_of_batch(batch_code):
membership = frappe.get_all("LMS Batch Membership", {"batch": get_batch(batch_code).name, "member": get_member_with_email()})
membership = frappe.get_all("LMS Batch Membership", {"batch": batch_code, "member": get_member_with_email()})
if len(membership):
return True
return False
@@ -29,9 +31,9 @@ def redirect_if_not_a_member(course,batch_code):
frappe.local.flags.redirect_location = "/courses/" + course
raise frappe.Redirect
def get_course(slug):
def get_course(name):
try:
return frappe.get_doc("LMS Course", {"slug": slug})
return frappe.get_doc("LMS Course", {"name": name})
except frappe.DoesNotExistError:
return
@@ -54,4 +56,4 @@ def get_batch_members(batch):
if membership.member_type == "Mentor":
member.is_mentor = True
members.append(member)
return members
return members

View File

@@ -182,8 +182,8 @@
{% for course in courses %}
<div class="dashboard__course">
<div class="dashboard__courseHeader">
<a class="text-decoration-none" target="_blank" href="/courses/{{course.slug}}">
<h5 class="w-75">{{ course.name }}</h5>
<a class="text-decoration-none" target="_blank" href="/courses/{{course.name}}">
<h5 class="w-75">{{ course.title }}</h5>
</a>
{% if course.member_type %}
<div class="dashboard__badge">

View File

@@ -1,31 +1,31 @@
{% macro InstructorsSection(instructor) %}
<h3>Instructor</h3>
<div class="instructor">
<div class="instructor-title">{{instructor.full_name}}</div>
<div class="instructor-subtitle">Created {{instructor.get_course_count()}} courses</div>
</div>
<h3>Instructor</h3>
<div class="instructor">
<div class="instructor-title">{{instructor.full_name}}</div>
<div class="instructor-subtitle">Created {{instructor.get_course_count()}} courses</div>
</div>
{% endmacro %}
{% macro MentorsSection(mentors, is_mentor, course_name) %}
<h3>Mentors</h3>
{% for m in mentors %}
<div class="instructor">
<div class="instructor-title">{{m.full_name}}</div>
<div class="instructor-subtitle">Mentored {{m.get_batch_count()}} batches</div>
</div>
{% endfor %}
{% if not is_mentor %}
<div id="mentor-request" class="notice">
Interested to become a mentor?
<h3>Mentors</h3>
{% for m in mentors %}
<div class="instructor">
<div class="instructor-title">{{m.full_name}}</div>
<div class="instructor-subtitle">Mentored {{m.get_batch_count()}} batches</div>
</div>
{% endfor %}
{% if not is_mentor %}
<div id="mentor-request" class="notice">
Interested to become a mentor?
<div><a id="apply-now" data-course="{{course_name | urlencode}}" href="">Apply Now!</a></div>
</div>
<div id="already-applied" class="notice hide">
You've applied to become a mentor for this course. Your request is currently under review.
<div><a id="apply-now" data-course="{{course_name | urlencode}}" href="">Apply Now!</a></div>
</div>
<div id="already-applied" class="notice hide">
You've applied to become a mentor for this course. Your request is currently under review.
If you are not any more interested to mentor this course, you can <a id="cancel-request" data-course="{{course_name | urlencode}}" href="">cancel your application</a>.
</div>
{% endif %}
If you are not any more interested to mentor this course, you can <a id="cancel-request" data-course="{{course_name | urlencode}}" href="">cancel your application</a>.
</div>
{% endif %}
{% endmacro %}

View File

@@ -108,30 +108,16 @@
<div class="tab-pane fade py-4 show active" role="tabpanel" id="home">
<div class='container'>
<div class="row row-cols-1 row-cols-xl-5 row-cols-lg-4 row-cols-md-3 row-cols-sm-2">
{% if sketches %}
{% if sketches %}
{% for sketch in sketches %}
<div class="col m-4">
<div class="card sketch-card" style="width: 200px;">
<div class="card-img-top">
<a href="/sketches/{{sketch.sketch_id}}">
{{ sketch.to_svg() }}
</a>
</div>
<div class="card-footer">
<div class="sketch-title">
<a href="sketches/{{sketch.sketch_id}}">{{sketch.title}}</a>
</div>
<div class="sketch-author">
by {{sketch.get_owner_name()}}
</div>
</div>
</div>
{{ widgets.SketchTeaser(sketch=sketch) }}
</div>
{% endfor %}
{% endif %}
{% endif %}
</div>
{% if not sketches %}
<p class="text-center">{{member.full_name}} has not created any skecth yet.</p>
<p class="text-center">{{member.full_name}} has not created any skecth yet.</p>
{% endif %}
</div>
</div>