diff --git a/community/community/doctype/community_event/community_event.json b/community/community/doctype/community_event/community_event.json
index 4068dc37..0042661f 100644
--- a/community/community/doctype/community_event/community_event.json
+++ b/community/community/doctype/community_event/community_event.json
@@ -7,6 +7,7 @@
"engine": "InnoDB",
"field_order": [
"year",
+ "is_hackathon",
"volunteers"
],
"fields": [
@@ -21,11 +22,17 @@
"fieldtype": "Table",
"label": "Volunteers",
"options": "Community Event Volunteer"
+ },
+ {
+ "default": "0",
+ "fieldname": "is_hackathon",
+ "fieldtype": "Check",
+ "label": "Is Hackathon"
}
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2021-02-12 18:29:21.213257",
+ "modified": "2021-02-15 18:29:26.828720",
"modified_by": "Administrator",
"module": "Community",
"name": "Community Event",
diff --git a/community/community/doctype/community_event_volunteer/community_event_volunteer.json b/community/community/doctype/community_event_volunteer/community_event_volunteer.json
index d61af225..ff60d161 100644
--- a/community/community/doctype/community_event_volunteer/community_event_volunteer.json
+++ b/community/community/doctype/community_event_volunteer/community_event_volunteer.json
@@ -11,6 +11,7 @@
{
"fieldname": "member",
"fieldtype": "Link",
+ "in_list_view": 1,
"label": "Member",
"options": "Community Member"
}
@@ -18,7 +19,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
- "modified": "2021-02-12 15:55:58.252902",
+ "modified": "2021-02-15 12:03:31.153575",
"modified_by": "Administrator",
"module": "Community",
"name": "Community Event Volunteer",
diff --git a/community/community/doctype/community_member/community_member.json b/community/community/doctype/community_member/community_member.json
index ab56836b..d6be86d9 100644
--- a/community/community/doctype/community_member/community_member.json
+++ b/community/community/doctype/community_member/community_member.json
@@ -15,7 +15,7 @@
],
"fields": [
{
- "default": "0",
+ "default": "1",
"fieldname": "enabled",
"fieldtype": "Check",
"label": "Enabled"
@@ -29,12 +29,14 @@
"unique": 1
},
{
+ "allow_in_quick_entry": 1,
"fieldname": "role",
"fieldtype": "Select",
"label": "Role",
"options": "\nBoard\nDirector\nVolunteer\nSpeaker"
},
{
+ "allow_in_quick_entry": 1,
"fieldname": "photo",
"fieldtype": "Attach Image",
"label": "Photo"
@@ -45,6 +47,7 @@
"label": "Short Intro"
},
{
+ "allow_in_quick_entry": 1,
"fieldname": "bio",
"fieldtype": "HTML Editor",
"label": "Bio"
@@ -52,7 +55,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2021-02-12 15:50:13.439527",
+ "modified": "2021-02-15 12:16:32.428546",
"modified_by": "Administrator",
"module": "Community",
"name": "Community Member",
diff --git a/community/community/doctype/community_project_member/community_project_member.json b/community/community/doctype/community_project_member/community_project_member.json
index e4e2cf9f..9a978409 100644
--- a/community/community/doctype/community_project_member/community_project_member.json
+++ b/community/community/doctype/community_project_member/community_project_member.json
@@ -27,10 +27,11 @@
"reqd": 1
},
{
+ "default": "Pending",
"fieldname": "status",
"fieldtype": "Select",
"label": "Status",
- "options": "\nPending\nAccepted\nRejected"
+ "options": "Pending\nAccepted\nRejected"
},
{
"fieldname": "project_owner",
@@ -41,7 +42,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2021-02-12 18:36:33.600885",
+ "modified": "2021-02-16 19:27:30.842282",
"modified_by": "Administrator",
"module": "Community",
"name": "Community Project Member",
diff --git a/community/community/utils.py b/community/community/utils.py
new file mode 100644
index 00000000..6da13fbf
--- /dev/null
+++ b/community/community/utils.py
@@ -0,0 +1 @@
+import frappe
\ No newline at end of file
diff --git a/community/www/hackathons/hackathon.html b/community/www/hackathons/hackathon.html
new file mode 100644
index 00000000..1abb6f3c
--- /dev/null
+++ b/community/www/hackathons/hackathon.html
@@ -0,0 +1,69 @@
+{% extends "templates/base.html" %}
+{% block title %}{{ hackathon }}{% endblock %}
+{% from "www/hackathons/macros/hero.html" import hero %}
+{% from "www/hackathons/macros/card.html" import null_card %}
+
+{% block head_include %}
+
+{% endblock %}
+
+
+{% macro card(project) %}
+
+{% endmacro %}
+
+{% block content %}
+
+ {{ hero(hackathon, {'name': 'Home', 'url': '/hackathons'}) }}
+
+
+ {% for project in projects %}
+ {{ card(project) }}
+ {% endfor %}
+ {% if projects %}
+ {% for n in range( (3 - (projects|length)) %3) %}
+ {{ null_card() }}
+ {% endfor %}
+ {% endif %}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/community/www/hackathons/hackathon.py b/community/www/hackathons/hackathon.py
new file mode 100644
index 00000000..f2c8b262
--- /dev/null
+++ b/community/www/hackathons/hackathon.py
@@ -0,0 +1,16 @@
+from __future__ import unicode_literals
+import frappe
+from frappe import _
+
+def get_context(context):
+ context.no_cache = 1
+ try:
+ hackathon = frappe.form_dict['hackathon']
+ except KeyError:
+ frappe.local.flags.redirect_location = '/hackathons'
+ raise frappe.Redirect
+ context.projects = get_hackathon_projects(hackathon)
+ context.hackathon = hackathon
+
+def get_hackathon_projects(hackathon):
+ return frappe.get_all("Community Project", filters={"event":hackathon}, fields=["name", "project_short_intro"])
\ No newline at end of file
diff --git a/community/www/hackathons/index.html b/community/www/hackathons/index.html
new file mode 100644
index 00000000..b8815cb1
--- /dev/null
+++ b/community/www/hackathons/index.html
@@ -0,0 +1,63 @@
+{% extends "templates/base.html" %}
+{% block title %}{{ 'Hackathons' }}{% endblock %}
+{% from "www/hackathons/macros/card.html" import hackathon_card %}
+{% from "www/hackathons/macros/card.html" import null_card %}
+{% block head_include %}
+
+
+
+{% endblock %}
+
+{% block content %}
+
+
+
{{ 'Hackathon' }}
+
+ {% if frappe.session.user == 'Guest' %}
+ {{_('Sign Up')}}
+ {% endif %}
+
+
+
+
+ {% for hackathon in hackathons %}
+ {{ hackathon_card(hackathon) }}
+ {% endfor %}
+ {% if hackathons %}
+ {% for n in range( (3 - (hackathons|length)) %3) %}
+ {{ null_card() }}
+ {% endfor %}
+ {% endif %}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/community/www/hackathons/index.py b/community/www/hackathons/index.py
new file mode 100644
index 00000000..f56d892f
--- /dev/null
+++ b/community/www/hackathons/index.py
@@ -0,0 +1,8 @@
+import frappe
+
+def get_context(context):
+ context.no_cache = 1
+ context.hackathons = get_hackathons()
+
+def get_hackathons():
+ return frappe.get_all("Community Event", filters={"is_hackathon": True})
\ No newline at end of file
diff --git a/community/www/hackathons/macros/card.html b/community/www/hackathons/macros/card.html
new file mode 100644
index 00000000..f70dab9d
--- /dev/null
+++ b/community/www/hackathons/macros/card.html
@@ -0,0 +1,18 @@
+{% macro hackathon_card(hackathon) %}
+
+{% endmacro %}
+
+{% macro null_card() %}
+
+{% endmacro %}
\ No newline at end of file
diff --git a/community/www/hackathons/macros/hero.html b/community/www/hackathons/macros/hero.html
new file mode 100644
index 00000000..c2753515
--- /dev/null
+++ b/community/www/hackathons/macros/hero.html
@@ -0,0 +1,15 @@
+{% macro hero(title, back) %}
+
+
+
{{ title }}
+
+ {% if frappe.session.user == 'Guest' %}
+ {{_('Sign Up')}}
+ {% endif %}
+
+
+{% endmacro %}
\ No newline at end of file
diff --git a/community/www/hackathons/project.html b/community/www/hackathons/project.html
new file mode 100644
index 00000000..60c8c0cc
--- /dev/null
+++ b/community/www/hackathons/project.html
@@ -0,0 +1,176 @@
+{% extends "templates/base.html" %}
+{% block title %}{{ hackathon }}{% endblock %}
+{% from "www/hackathons/macros/hero.html" import hero %}
+{% from "www/hackathons/macros/card.html" import null_card %}
+{% block head_include %}
+
+
+
+{% endblock %}
+
+{% macro show_user(user) %}
+ {{ frappe.db.get_value("User", user, "full_name") }}
+{% endmacro %}
+
+{% block content %}
+
+ {{ hero(project, {'name': hackathon, 'url': '/hackathons/hackathon?hackathon=' + hackathon}) }}
+
+ {% if project %}
+
{{project.project_name}}
+
+ {% if frappe.session.user != "Guest" %}
+ {% if is_owner %}
+
+
Owner
+
+ {% endif %}
+ {% if is_member %}
+
+
Member
+
+ {% endif %}
+ {% endif %}
+
+
{{ project.project_short_intro[:220] }}
+ {% if project.repository_link %}
+
Respository
+ {% endif %}
+ {% if project.video_link %}
+
Video ▶️
+ {% endif %}
+
👍
+
+
+
+
+
+
+
+ {{ frappe.utils.md_to_html(project.project_description or "No README created yet") }}
+
+
+
+
+
+
+
+
+
{{ show_user(project.owner) }}
+
+ {% for member in members %}
+ {% set is_user = member.owner == frappe.session.user %}
+ {% set is_pending = is_user and member.status=="Pending" %}
+ {% if member.status == "Accepted" %}
+
+ {{ show_user(member.owner) }}
+ {% if is_user %}
+ Leave
+ {% endif %}
+
+ {% elif member.status == "Pending" and is_owner %}
+
Join request from:
{{ show_user(member.owner) }}
+
{{ member.intro }}
+
+ Accept
+ Reject
+
+
+ {% endif %}
+ {% endfor %}
+
+
+ {% if frappe.session.user != 'Guest' %}
+
+ {% if not (my_project or is_member or is_pending) and project.accepting_members %}
+
Join
+ {{ project.project_name }}
+ {% elif is_pending %}
+
Your application is pending
+ {% endif %}
+ {% endif %}
+
+
+
+
+
+ {% macro add_update(update, date) %}
+
+ {{ frappe.utils.md_to_html(update or '') }}
+
{{ frappe.format_date(date) }}
+
+ {% endmacro %}
+
+ {% if frappe.session.user != 'Guest' and (is_owner or is_member) %}
+
+ Add
+ Update
+
+ {% endif %}
+
+
+
+
+
+ {% for update in updates %}
+ {{ add_update(update.project_update, update.creation) }}
+ {% endfor %}
+
+
+ {{ add_update("Project created by " + frappe.db.get_value('User', project.owner, 'full_name'),
+ project.creation) }}
+
+
+
+
+ {% endif %}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/community/www/hackathons/project.js b/community/www/hackathons/project.js
new file mode 100644
index 00000000..7f493a9b
--- /dev/null
+++ b/community/www/hackathons/project.js
@@ -0,0 +1,41 @@
+$('#req-evals').on('click', () => {
+ frappe.msgprint("The evaluations have been moved to Telegram ")
+})
+var set_likes = function(liked, likes) {
+ let $btn = $('.btn-like');
+ $btn.text(`${likes} 👍`);
+ if (liked) {
+ $btn.addClass('btn-secondary').removeClass('btn-default');
+ } else {
+ $btn.addClass('btn-default').removeClass('btn-secondary');
+ }
+};
+
+// set initial
+//set_likes(liked, likes);
+
+// like - unlike
+$('.btn-like').on('click', () => {
+ frappe.call('like', {project: project}, (data) => {
+ set_likes(data.message.action =="Liked", data.message.likes);
+ });
+});
+
+// accept / reject
+$('.btn-accept').on('click', (ev) => {
+ frappe.call('join_request', {id: $(ev.target).attr('data-request-id'), action: 'Accept'}, (data) => {
+ window.location.reload();
+ });
+});
+
+$('.btn-reject').on('click', (ev) => {
+ frappe.call('join_request', {id: $(ev.target).attr('data-request-id'), action: 'Reject'}, (data) => {
+ window.location.reload();
+ });
+});
+
+$('.btn-leave').on('click', (ev) => {
+ frappe.call('join_request', {id: $(ev.target).attr('data-request-id'), action: 'Reject'}, (data) => {
+ window.location.reload();
+ });
+});
\ No newline at end of file
diff --git a/community/www/hackathons/project.py b/community/www/hackathons/project.py
new file mode 100644
index 00000000..af2ee61d
--- /dev/null
+++ b/community/www/hackathons/project.py
@@ -0,0 +1,57 @@
+from __future__ import unicode_literals
+import frappe
+from frappe import _
+
+def get_context(context):
+ context.no_cache = 1
+ try:
+ project = frappe.form_dict['project']
+ hackathon = frappe.form_dict['hackathon']
+ except KeyError:
+ frappe.local.flags.redirect_location = '/hackathons'
+ raise frappe.Redirect
+ context.project = get_project(project)
+ context.hackathon = hackathon
+ context.members = get_members(project)
+ context.confirmed_members = get_comfirmed_members(project)
+ context.likes = get_project_likes(project)
+ context.updates = get_updates(project)
+ if frappe.session.user != "Guest":
+ context.my_project = get_my_projects()
+ context.is_owner = context.project.owner == frappe.session.user
+ context.accepted_members = get_accepted_members(project)
+ context.is_member = check_is_member(project)
+ context.liked = get_liked_project(project)
+
+def get_project(project_name):
+ try:
+ return frappe.get_doc('Community Project', project_name)
+ except frappe.DoesNotExistError:
+ frappe.throw(_("Project {0} does not exist.").format(project_name))
+
+def get_members(project_name):
+ return frappe.get_all("Community Project Member", {"project": project_name, "status": ("!=", "Rejected") }, ['name', "owner", "status", 'intro'])
+
+def get_comfirmed_members(project_name):
+ return frappe.get_all("Community Project Member", {"project": project_name, "status": ("=", "Accepted") }, ['name'])
+
+def get_project_likes(project_name):
+ return frappe.get_all("Community Project Like", {"project": project_name})
+
+def get_updates(project_name):
+ return frappe.get_all('Community Project Update', {"project": project_name}, ['owner', 'creation', 'update'])
+
+def get_accepted_members(project_name):
+ return frappe.get_all("Community Project Member", {"project": project_name, "status": "Accepted" })
+
+def get_my_projects():
+ my_project = frappe.db.get_value('Community Project', {"owner": frappe.session.user})
+ if not my_project:
+ my_project = frappe.db.get_value('Community Project Member', {"owner": frappe.session.user, "status": 'Accepted'}, 'project')
+ return my_project
+
+def check_is_member(project_name):
+ frappe.get_all("Community Project Member", {"project": project_name, "status": "Accepted", "owner": frappe.session.user })
+
+def get_liked_project(project_name):
+ return frappe.db.get_value("Community Project Like", {"owner": frappe.session.user, "project": project_name})
\ No newline at end of file