refactor: seperate module for hackathon

This commit is contained in:
pateljannat
2021-03-04 20:11:18 +05:30
parent acea59767d
commit 8b5cd8e6c6
50 changed files with 249 additions and 79 deletions

View File

@@ -5,7 +5,8 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"course"
"course",
"user"
],
"fields": [
{
@@ -13,11 +14,17 @@
"fieldtype": "Link",
"label": "Course",
"options": "Community Course"
},
{
"fieldname": "user",
"fieldtype": "Data",
"label": "User",
"options": "Email"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-03-03 11:44:32.011805",
"modified": "2021-03-04 18:24:22.654503",
"modified_by": "Administrator",
"module": "Community",
"name": "Community Course Enrollment",

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2021, Frappe and contributors
// Copyright (c) 2021, FOSS United and contributors
// For license information, please see license.txt
frappe.ui.form.on('Community Hackathon', {

View File

@@ -34,9 +34,9 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-02-17 12:44:25.198010",
"modified": "2021-03-04 19:57:22.618153",
"modified_by": "Administrator",
"module": "Community",
"module": "Hackathon",
"name": "Community Hackathon",
"owner": "Administrator",
"permissions": [

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and contributors
# Copyright (c) 2021, FOSS United and contributors
# For license information, please see license.txt
from __future__ import unicode_literals

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and Contributors
# Copyright (c) 2021, FOSS United and Contributors
# See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2021, Frappe and contributors
// Copyright (c) 2021, FOSS United and contributors
// For license information, please see license.txt
frappe.ui.form.on('Community Project', {

View File

@@ -59,6 +59,12 @@
"fieldtype": "Markdown Editor",
"label": "Project Description"
},
{
"fieldname": "hackathon",
"fieldtype": "Link",
"label": "Hackathon",
"options": "Community Hackathon"
},
{
"default": "0",
"fieldname": "accepting_members",
@@ -76,19 +82,13 @@
"fieldtype": "Small Text",
"hidden": 1,
"label": "Project Search"
},
{
"fieldname": "hackathon",
"fieldtype": "Link",
"label": "Hackathon",
"options": "Community Hackathon"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-02-24 15:52:56.588565",
"modified": "2021-03-04 19:59:33.450666",
"modified_by": "Administrator",
"module": "Community",
"module": "Hackathon",
"name": "Community Project",
"owner": "Administrator",
"permissions": [

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and contributors
# Copyright (c) 2021, FOSS United and contributors
# For license information, please see license.txt
from __future__ import unicode_literals

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and Contributors
# Copyright (c) 2021, FOSS United and Contributors
# See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2021, Frappe and contributors
// Copyright (c) 2021, FOSS United and contributors
// For license information, please see license.txt
frappe.ui.form.on('Community Project Evaluation', {

View File

@@ -123,9 +123,9 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-02-12 19:44:57.467599",
"modified": "2021-03-04 19:56:53.757808",
"modified_by": "Administrator",
"module": "Community",
"module": "Hackathon",
"name": "Community Project Evaluation",
"owner": "Administrator",
"permissions": [

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and contributors
# Copyright (c) 2021, FOSS United and contributors
# For license information, please see license.txt
from __future__ import unicode_literals

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and Contributors
# Copyright (c) 2021, FOSS United and Contributors
# See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2021, Frappe and contributors
// Copyright (c) 2021, FOSS United and contributors
// For license information, please see license.txt
frappe.ui.form.on('Community Project Like', {

View File

@@ -17,9 +17,9 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-02-12 18:43:24.206708",
"modified": "2021-03-04 18:55:51.877522",
"modified_by": "Administrator",
"module": "Community",
"module": "Hackathon",
"name": "Community Project Like",
"owner": "Administrator",
"permissions": [

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and contributors
# Copyright (c) 2021, FOSS United and contributors
# For license information, please see license.txt
from __future__ import unicode_literals

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and Contributors
# Copyright (c) 2021, FOSS United and Contributors
# See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2021, Frappe and contributors
// Copyright (c) 2021, FOSS United and contributors
// For license information, please see license.txt
frappe.ui.form.on('Community Project Member', {

View File

@@ -42,9 +42,9 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-02-16 19:27:30.842282",
"modified": "2021-03-04 19:44:09.832170",
"modified_by": "Administrator",
"module": "Community",
"module": "Hackathon",
"name": "Community Project Member",
"owner": "Administrator",
"permissions": [

View File

@@ -1,17 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and contributors
# Copyright (c) 2021, FOSS United and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
# import frappe
from frappe.model.document import Document
class CommunityProjectMember(Document):
def validate(self):
def validate(self):
self.validate_if_already_member()
def validate_if_already_member(self):
if frappe.get_all("Community Project Member", {"owner": self.owner}):
frappe.throw(_("You have already applied for the membership of this project."))

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and Contributors
# Copyright (c) 2021, FOSS United and Contributors
# See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2021, Frappe and contributors
// Copyright (c) 2021, FOSS United and contributors
// For license information, please see license.txt
frappe.ui.form.on('Community Project Update', {

View File

@@ -27,9 +27,9 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-02-12 18:45:56.750969",
"modified": "2021-03-04 19:43:10.886773",
"modified_by": "Administrator",
"module": "Community",
"module": "Hackathon",
"name": "Community Project Update",
"owner": "Administrator",
"permissions": [

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and contributors
# Copyright (c) 2021, FOSS United and contributors
# For license information, please see license.txt
from __future__ import unicode_literals

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe and Contributors
# Copyright (c) 2021, FOSS United and Contributors
# See license.txt
from __future__ import unicode_literals

View File

View File

@@ -0,0 +1,3 @@
frappe.ready(function() {
// bind events here
})

View File

@@ -0,0 +1,64 @@
{
"accept_payment": 0,
"allow_comments": 0,
"allow_delete": 0,
"allow_edit": 0,
"allow_incomplete": 0,
"allow_multiple": 0,
"allow_print": 0,
"amount": 0.0,
"amount_based_on_field": 0,
"apply_document_permissions": 0,
"button_label": "Send Request",
"client_script": "$('.page-header h2').html(`Request to Join \"${frappe.utils.get_url_arg('project_name')}\"`);",
"creation": "2021-02-17 13:20:08.548735",
"doc_type": "Community Project Member",
"docstatus": 0,
"doctype": "Web Form",
"idx": 0,
"is_standard": 1,
"login_required": 0,
"max_attachment_size": 0,
"modified": "2021-03-04 19:43:53.697037",
"modified_by": "Administrator",
"module": "Hackathon",
"name": "join-request",
"owner": "Administrator",
"payment_button_label": "Buy Now",
"published": 1,
"route": "join-request",
"route_to_success_link": 0,
"show_attachments": 0,
"show_in_grid": 0,
"show_sidebar": 0,
"sidebar_items": [],
"success_url": "/join-request",
"title": "Join Request",
"web_form_fields": [
{
"allow_read_on_all_link_options": 0,
"fieldname": "project",
"fieldtype": "Link",
"hidden": 0,
"label": "Project",
"max_length": 0,
"max_value": 0,
"options": "Community Project",
"read_only": 0,
"reqd": 1,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "intro",
"fieldtype": "Small Text",
"hidden": 0,
"label": "Intro",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 1,
"show_in_filter": 0
}
]
}

View File

@@ -0,0 +1,7 @@
from __future__ import unicode_literals
import frappe
def get_context(context):
# do your magic here
pass

View File

@@ -0,0 +1,3 @@
frappe.ready(function() {
// bind events here
})

View File

@@ -0,0 +1,63 @@
{
"accept_payment": 0,
"allow_comments": 0,
"allow_delete": 0,
"allow_edit": 0,
"allow_incomplete": 0,
"allow_multiple": 0,
"allow_print": 0,
"amount": 0.0,
"amount_based_on_field": 0,
"apply_document_permissions": 0,
"button_label": "Submit",
"creation": "2021-02-18 13:15:09.464515",
"doc_type": "Community Project Update",
"docstatus": 0,
"doctype": "Web Form",
"idx": 0,
"is_standard": 1,
"login_required": 1,
"max_attachment_size": 0,
"modified": "2021-03-04 19:43:28.957577",
"modified_by": "Administrator",
"module": "Hackathon",
"name": "project-update",
"owner": "Administrator",
"payment_button_label": "Buy Now",
"published": 1,
"route": "project-update",
"route_to_success_link": 0,
"show_attachments": 0,
"show_in_grid": 0,
"show_sidebar": 0,
"sidebar_items": [],
"success_url": "/project-update",
"title": "Project Update",
"web_form_fields": [
{
"allow_read_on_all_link_options": 0,
"fieldname": "project",
"fieldtype": "Link",
"hidden": 0,
"label": "Project",
"max_length": 0,
"max_value": 0,
"options": "Community Project",
"read_only": 0,
"reqd": 1,
"show_in_filter": 0
},
{
"allow_read_on_all_link_options": 0,
"fieldname": "update",
"fieldtype": "Data",
"hidden": 0,
"label": "Update",
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 1,
"show_in_filter": 0
}
]
}

View File

@@ -0,0 +1,7 @@
from __future__ import unicode_literals
import frappe
def get_context(context):
# do your magic here
pass

View File

View File

@@ -1 +1,3 @@
Community
Community
Hackathon
LMS

View File

@@ -16,13 +16,9 @@
<li class="breadcrumb-item" aria-current="page"><a href="/courses">Courses</a></li>
</ol>
</nav>
{% if course_enrolled %}
<p>
<div class="badge badge-info">Enrolled</div>
</p>
{% endif %}
<div class="badge badge-info enrollment-badge hide">Enrolled</div>
<div>
{% if not course_enrolled %}
{% if not course_enrolled and frappe.session.user != "Guest" %}
<button class="btn btn-dark btn-enroll float-right" data-course={{course.name}}>Enroll</button>
{% endif %}
<h1>{{ course.title }}</h1>

View File

@@ -1,17 +1,22 @@
/* frappe.ready(() => {
var url_params = new URLSearchParams(window.location.search);
frappe.call('community.www.courses.course.has_enrolled', { course: url_params.get("course") }, (data) => {
if (data.message) {
$(".btn-enroll").addClass("hide");
$(".enrollment-details").removeClass("hide");
}
})
}) */
frappe.ready(() => {
if(frappe.session.user != "Guest"){
var url_params = new URLSearchParams(window.location.search);
frappe.call('community.www.courses.course.has_enrolled', { course: url_params.get("course") }, (data) => {
if (data.message) {
show_enrollment_badge()
}
})
}
})
var show_enrollment_badge = () => {
$(".btn-enroll").addClass("hide");
$(".enrollment-badge").removeClass("hide");
}
$('.btn-enroll').on('click', (e) => {
frappe.call('community.www.courses.course.enroll', { course: $(e.target).attr("data-course") }, (data) => {
$(".btn-enroll").addClass("hide");
$(".enrollment-details").removeClass("hide");
});
frappe.call('community.www.courses.course.enroll', { course: $(e.target).attr("data-course") }, (data) => {
show_enrollment_badge()
});
});

View File

@@ -22,6 +22,7 @@ def get_course(name):
)
return course
@frappe.whitelist()
def has_enrolled(course):
return frappe.db.get_value("Community Course Enrollment", {"course": course, "owner": frappe.session.user})
@@ -29,7 +30,8 @@ def has_enrolled(course):
def enroll(course):
return frappe.get_doc({
"doctype": "Community Course Enrollment",
"course": course
"course": course,
"user": frappe.session.user
}).save()

View File

@@ -9,5 +9,4 @@ def get_courses():
"Community Course",
fields=['name', 'title', 'description']
)
print(courses)
return courses

View File

@@ -8,8 +8,6 @@ def get_context(context):
topic_name = get_queryparam("topic", '/courses?course=' + course_name)
context.topic = get_topic(course_name, topic_name)
print("topic", context.topic)
def get_queryparam(name, redirect_when_not_found):
try:
return frappe.form_dict[name]

View File

@@ -31,6 +31,13 @@
padding: 20px;
}
.no-courses {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
section {
padding: 5rem 0 5rem 0;
}
@@ -40,11 +47,11 @@
{% macro card(course) %}
<div class="col-sm-4 mb-4 text-left">
<a href="//courses/course?course={{course.name}}" class="no-decoration no-underline">
<div class="card h-100">
<div class='card-body'>
<h5 class='card-title'>{{ course.title }}</h5>
<div class="card h-100">
<div class='card-body'>
<h5 class='card-title'>{{ course.title }}</h5>
</div>
</div>
</div>
</a>
</div>
{% endmacro %}
@@ -52,16 +59,24 @@
{% block content %}
<section class="section">
<div class='container'>
<div class="row mt-5">
{% for course in my_courses %}
{{ card(course) }}
{% endfor %}
{% if my_courses %}
{% for n in range( (3 - (my_courses|length)) %3) %}
{{ null_card() }}
{% endfor %}
{% endif %}
{% if frappe.session.user != "Guest" %}
{% for course in my_courses %}
{{ card(course) }}
{% endfor %}
{% if my_courses %}
{% for n in range( (3 - (my_courses|length)) %3) %}
{{ null_card() }}
{% endfor %}
{% else %}
<div class="no-courses">You haven't enrolled in any Course yet. <a href="/courses">Check out the availabe
courses.</a></div>
{% endif %}
{% else %}
<div class="no-courses">
<p>Please sign up to access this page.</p>
<a id="signup" class="btn btn-primary btn-lg" href="/login#signup">{{_('Sign Up')}}</a>
</div>
{% endif %}
</div>
</section>
{% endblock %}