feat: paid course from course creation form
This commit is contained in:
@@ -122,6 +122,10 @@
|
||||
|
||||
{{ Notes(course) }}
|
||||
|
||||
<div class="vertically-center mb-3 bold-heading">
|
||||
{{ format_amount(course.course_price, course.currency) }}
|
||||
</div>
|
||||
|
||||
<div class="vertically-center mb-3">
|
||||
<svg class="icon icon-md mr-1">
|
||||
<use class="" href="#icon-users">
|
||||
@@ -194,18 +198,18 @@
|
||||
membership.current_lesson else "1.1" if first_lesson_exists(course.name) else None %}
|
||||
|
||||
<div class="all-cta">
|
||||
{% if is_instructor(course.name) and not course.published and course.status != "Under Review" %}
|
||||
{% if is_instructor and not course.published and course.status != "Under Review" %}
|
||||
<div class="btn btn-primary wide-button" id="submit-for-review" data-course="{{ course.name | urlencode }}">
|
||||
{{ _("Submit for Review") }}
|
||||
</div>
|
||||
|
||||
{% elif is_instructor(course.name) and lesson_index %}
|
||||
{% elif is_instructor and lesson_index %}
|
||||
<a class="btn btn-primary wide-button" id="continue-learning"
|
||||
href="{{ get_lesson_url(course.name, lesson_index) }}{{ course.query_parameter }}">
|
||||
{{ _("Checkout Course") }}
|
||||
</a>
|
||||
|
||||
{% elif course.upcoming and not is_user_interested and not is_instructor(course.name) %}
|
||||
{% elif course.upcoming and not is_user_interested and not is_instructor %}
|
||||
<div class="btn btn-secondary wide-button notify-me" data-course="{{course.name | urlencode}}">
|
||||
{{ _("Notify me when available") }}
|
||||
</div>
|
||||
@@ -221,7 +225,7 @@
|
||||
{{ _("Continue Learning") }}
|
||||
</a>
|
||||
|
||||
{% elif course.paid_course %}
|
||||
{% elif course.paid_course and not is_instructor %}
|
||||
<a class="btn btn-primary wide-button" href="/billing/{{ course.name | urlencode }}">
|
||||
{{ _("Buy This Course") }}
|
||||
</a>
|
||||
@@ -247,7 +251,7 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if is_instructor(course.name) or has_course_moderator_role() %}
|
||||
{% if is_instructor or has_course_moderator_role() %}
|
||||
<a class="btn btn-secondary wide-button mt-2" title="Edit Course" href="/courses/{{ course.name }}/edit">
|
||||
<!-- <svg class="icon icon-md">
|
||||
<use href="#icon-edit"></use>
|
||||
@@ -266,7 +270,7 @@
|
||||
{{ _("You have opted to be notified for this course. You will receive an email when the course becomes available.") }}
|
||||
</div>
|
||||
|
||||
{% if course.status == "Under Review" and is_instructor(course.name) %}
|
||||
{% if course.status == "Under Review" and is_instructor %}
|
||||
<div class="mb-4">
|
||||
{{ _("This course is currently under review. Once the review is complete, the System Admins will publish it on the website.") }}
|
||||
</div>
|
||||
|
||||
@@ -88,6 +88,7 @@ def set_course_context(context, course_name):
|
||||
"?batch=" + membership.batch if membership and membership.batch else ""
|
||||
)
|
||||
context.membership = membership
|
||||
context.is_instructor = is_instructor(course.name)
|
||||
context.certificate = is_certified(course.name)
|
||||
eval_details = get_evaluation_details(course.name)
|
||||
context.eligible_for_evaluation = eval_details.eligible
|
||||
|
||||
@@ -157,6 +157,43 @@
|
||||
<img {% if course.image %} class="image-preview" src="{{ course.image }}" {% endif %}>
|
||||
</div>
|
||||
|
||||
<div class="field-group">
|
||||
<label for="paid_course" class="vertically-center mb-0">
|
||||
<input type="checkbox" id="paid-course" {% if course.paid_course %} checked {% endif %}>
|
||||
{{ _("Paid Course") }}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="field-group price-field {% if not course.paid_course %} hide {% endif %}">
|
||||
<div class="field-label {% if course.paid_course %} reqd {% endif %}">
|
||||
{{ _("Course Price") }}
|
||||
</div>
|
||||
<div class="field-description">
|
||||
{{ _("The price of this course.") }}
|
||||
</div>
|
||||
<div class="">
|
||||
<input id="course-price" type="number" class="field-input" {% if course.course_price %} value="{{ course.course_price }}" {% endif %}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field-group price-field {% if not course.paid_course %} hide {% endif %}">
|
||||
<div class="field-label {% if course.paid_course %} reqd {% endif %}">
|
||||
{{ _("Currency") }}
|
||||
</div>
|
||||
<div class="field-description">
|
||||
{{ _("The currency in which users will pay for this course.") }}
|
||||
</div>
|
||||
|
||||
<select class="field-input" id="currency">
|
||||
<option></option>
|
||||
{% for currency in currencies %}
|
||||
<option value="{{ currency }}" {% if currency == course.currency %} selected {% endif %}>
|
||||
{{ currency}}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="field-group">
|
||||
<div class="field-label">
|
||||
{{ _("Instructor") }}
|
||||
|
||||
@@ -41,6 +41,10 @@ frappe.ready(() => {
|
||||
$(".btn-upload").click((e) => {
|
||||
upload_file(e);
|
||||
});
|
||||
|
||||
$("#paid-course").click((e) => {
|
||||
setup_paid_course(e);
|
||||
});
|
||||
});
|
||||
|
||||
const create_tag = (e) => {
|
||||
@@ -79,6 +83,9 @@ const save_course = (e) => {
|
||||
: "",
|
||||
published: $("#published").prop("checked") ? 1 : 0,
|
||||
upcoming: $("#upcoming").prop("checked") ? 1 : 0,
|
||||
paid_course: $("#paid-course").prop("checked") ? 1 : 0,
|
||||
course_price: $("#course-price").val(),
|
||||
currency: $("#currency").val(),
|
||||
},
|
||||
callback: (data) => {
|
||||
frappe.show_alert({
|
||||
@@ -167,3 +174,13 @@ const upload_file = (e) => {
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const setup_paid_course = (e) => {
|
||||
if ($(e.target).prop("checked")) {
|
||||
$(".price-field").removeClass("hide");
|
||||
$(".price-field").find(".field-label").addClass("reqd");
|
||||
} else {
|
||||
$(".price-field").addClass("hide");
|
||||
$(".price-field").find(".field-label").removeClass("reqd");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -35,6 +35,7 @@ def get_context(context):
|
||||
context.member = frappe.db.get_value(
|
||||
"User", frappe.session.user, ["full_name", "username"], as_dict=True
|
||||
)
|
||||
context.currencies = frappe.get_all("Currency", {"enabled": 1}, pluck="currency_name")
|
||||
|
||||
|
||||
def set_course_context(context, course_name):
|
||||
@@ -51,8 +52,8 @@ def set_course_context(context, course_name):
|
||||
"video_link",
|
||||
"enable_certification",
|
||||
"grant_certificate_after",
|
||||
"paid_certificate",
|
||||
"price_certificate",
|
||||
"paid_course",
|
||||
"course_price",
|
||||
"currency",
|
||||
"max_attempts",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user