From 97db066922e72515ba24cb0c3ae96aa3594b107f Mon Sep 17 00:00:00 2001 From: pateljannat Date: Fri, 19 Feb 2021 10:36:34 +0530 Subject: [PATCH] feat: project, talks, update pages and web forms --- .../doctype/community_hackathon/__init__.py | 0 .../community_hackathon.js | 8 ++ .../community_hackathon.json | 60 ++++++++++++++ .../community_hackathon.py | 10 +++ .../test_community_hackathon.py | 10 +++ .../community_project/community_project.json | 16 ++-- .../community_project_member.py | 11 ++- .../doctype/community_talk/__init__.py | 0 .../doctype/community_talk/community_talk.js | 8 ++ .../community_talk/community_talk.json | 80 +++++++++++++++++++ .../doctype/community_talk/community_talk.py | 10 +++ .../community_talk/test_community_talk.py | 10 +++ community/community/web_form/__init__.py | 0 .../web_form/join_request/__init__.py | 0 .../web_form/join_request/join_request.js | 3 + .../web_form/join_request/join_request.json | 64 +++++++++++++++ .../web_form/join_request/join_request.py | 7 ++ .../web_form/project_update/__init__.py | 0 .../web_form/project_update/project_update.js | 8 ++ .../project_update/project_update.json | 63 +++++++++++++++ .../web_form/project_update/project_update.py | 7 ++ community/community/web_template/__init__.py | 0 community/www/hackathons/hackathon.html | 78 +++++++++++++++--- community/www/hackathons/hackathon.py | 11 ++- community/www/hackathons/index.html | 4 +- community/www/hackathons/index.py | 2 +- community/www/hackathons/macros/hero.html | 4 +- community/www/hackathons/macros/navbar.html | 16 ++++ community/www/hackathons/macros/user.html | 3 + community/www/hackathons/project.html | 12 ++- community/www/hackathons/project.js | 12 +-- community/www/hackathons/project.py | 17 +++- 32 files changed, 493 insertions(+), 41 deletions(-) create mode 100644 community/community/doctype/community_hackathon/__init__.py create mode 100644 community/community/doctype/community_hackathon/community_hackathon.js create mode 100644 community/community/doctype/community_hackathon/community_hackathon.json create mode 100644 community/community/doctype/community_hackathon/community_hackathon.py create mode 100644 community/community/doctype/community_hackathon/test_community_hackathon.py create mode 100644 community/community/doctype/community_talk/__init__.py create mode 100644 community/community/doctype/community_talk/community_talk.js create mode 100644 community/community/doctype/community_talk/community_talk.json create mode 100644 community/community/doctype/community_talk/community_talk.py create mode 100644 community/community/doctype/community_talk/test_community_talk.py create mode 100644 community/community/web_form/__init__.py create mode 100644 community/community/web_form/join_request/__init__.py create mode 100644 community/community/web_form/join_request/join_request.js create mode 100644 community/community/web_form/join_request/join_request.json create mode 100644 community/community/web_form/join_request/join_request.py create mode 100644 community/community/web_form/project_update/__init__.py create mode 100644 community/community/web_form/project_update/project_update.js create mode 100644 community/community/web_form/project_update/project_update.json create mode 100644 community/community/web_form/project_update/project_update.py create mode 100644 community/community/web_template/__init__.py create mode 100644 community/www/hackathons/macros/navbar.html create mode 100644 community/www/hackathons/macros/user.html diff --git a/community/community/doctype/community_hackathon/__init__.py b/community/community/doctype/community_hackathon/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/community/community/doctype/community_hackathon/community_hackathon.js b/community/community/doctype/community_hackathon/community_hackathon.js new file mode 100644 index 00000000..91812b8a --- /dev/null +++ b/community/community/doctype/community_hackathon/community_hackathon.js @@ -0,0 +1,8 @@ +// Copyright (c) 2021, Frappe and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Community Hackathon', { + // refresh: function(frm) { + + // } +}); diff --git a/community/community/doctype/community_hackathon/community_hackathon.json b/community/community/doctype/community_hackathon/community_hackathon.json new file mode 100644 index 00000000..cd6749e8 --- /dev/null +++ b/community/community/doctype/community_hackathon/community_hackathon.json @@ -0,0 +1,60 @@ +{ + "actions": [], + "autoname": "field:hackathon_name", + "creation": "2021-02-17 12:40:25.604012", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "hackathon_name", + "organizer", + "year" + ], + "fields": [ + { + "fieldname": "hackathon_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Hackathon Name", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "organizer", + "fieldtype": "Data", + "label": "Organizer", + "options": "Email" + }, + { + "fieldname": "year", + "fieldtype": "Select", + "label": "Year", + "options": "\n2021\n2022\n2023\n2024\n2025" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2021-02-17 12:44:25.198010", + "modified_by": "Administrator", + "module": "Community", + "name": "Community Hackathon", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/community/community/doctype/community_hackathon/community_hackathon.py b/community/community/doctype/community_hackathon/community_hackathon.py new file mode 100644 index 00000000..88e85e5e --- /dev/null +++ b/community/community/doctype/community_hackathon/community_hackathon.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2021, Frappe and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +# import frappe +from frappe.model.document import Document + +class CommunityHackathon(Document): + pass diff --git a/community/community/doctype/community_hackathon/test_community_hackathon.py b/community/community/doctype/community_hackathon/test_community_hackathon.py new file mode 100644 index 00000000..1850b9ec --- /dev/null +++ b/community/community/doctype/community_hackathon/test_community_hackathon.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2021, Frappe and Contributors +# See license.txt +from __future__ import unicode_literals + +# import frappe +import unittest + +class TestCommunityHackathon(unittest.TestCase): + pass diff --git a/community/community/doctype/community_project/community_project.json b/community/community/doctype/community_project/community_project.json index 029b536c..6e0b4b33 100644 --- a/community/community/doctype/community_project/community_project.json +++ b/community/community/doctype/community_project/community_project.json @@ -13,7 +13,7 @@ "video_link", "telegram_id", "project_description", - "event", + "hackathon", "accepting_members", "likes", "project_search" @@ -58,12 +58,6 @@ "fieldtype": "Markdown Editor", "label": "Project Description" }, - { - "fieldname": "event", - "fieldtype": "Link", - "label": "Event", - "options": "Community Event" - }, { "default": "0", "fieldname": "accepting_members", @@ -79,11 +73,17 @@ "fieldname": "project_search", "fieldtype": "Small Text", "label": "Project Search" + }, + { + "fieldname": "hackathon", + "fieldtype": "Link", + "label": "Hackathon", + "options": "Community Hackathon" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-02-12 18:28:33.440328", + "modified": "2021-02-17 12:41:32.562346", "modified_by": "Administrator", "module": "Community", "name": "Community Project", diff --git a/community/community/doctype/community_project_member/community_project_member.py b/community/community/doctype/community_project_member/community_project_member.py index 8a607c36..3e14fd09 100644 --- a/community/community/doctype/community_project_member/community_project_member.py +++ b/community/community/doctype/community_project_member/community_project_member.py @@ -3,8 +3,15 @@ # For license information, please see license.txt from __future__ import unicode_literals -# import frappe +import frappe +from frappe import _ from frappe.model.document import Document class CommunityProjectMember(Document): - pass + + 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.")) diff --git a/community/community/doctype/community_talk/__init__.py b/community/community/doctype/community_talk/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/community/community/doctype/community_talk/community_talk.js b/community/community/doctype/community_talk/community_talk.js new file mode 100644 index 00000000..efeca6b4 --- /dev/null +++ b/community/community/doctype/community_talk/community_talk.js @@ -0,0 +1,8 @@ +// Copyright (c) 2021, Frappe and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Community Talk', { + // refresh: function(frm) { + + // } +}); diff --git a/community/community/doctype/community_talk/community_talk.json b/community/community/doctype/community_talk/community_talk.json new file mode 100644 index 00000000..0df953ba --- /dev/null +++ b/community/community/doctype/community_talk/community_talk.json @@ -0,0 +1,80 @@ +{ + "actions": [], + "autoname": "field:topic", + "creation": "2021-02-18 16:06:59.882799", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "speaker", + "topic", + "video_link", + "date_and_time", + "event_type", + "event" + ], + "fields": [ + { + "fieldname": "speaker", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Speaker", + "reqd": 1 + }, + { + "fieldname": "topic", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Topic", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "video_link", + "fieldtype": "Data", + "label": "Video Link" + }, + { + "fieldname": "date_and_time", + "fieldtype": "Datetime", + "label": "Date and Time" + }, + { + "fieldname": "event_type", + "fieldtype": "Link", + "label": "Event Type", + "options": "DocType" + }, + { + "fieldname": "event", + "fieldtype": "Dynamic Link", + "label": "Event", + "options": "event_type" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2021-02-18 16:56:41.526184", + "modified_by": "Administrator", + "module": "Community", + "name": "Community Talk", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/community/community/doctype/community_talk/community_talk.py b/community/community/doctype/community_talk/community_talk.py new file mode 100644 index 00000000..53d939e6 --- /dev/null +++ b/community/community/doctype/community_talk/community_talk.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2021, Frappe and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +# import frappe +from frappe.model.document import Document + +class CommunityTalk(Document): + pass diff --git a/community/community/doctype/community_talk/test_community_talk.py b/community/community/doctype/community_talk/test_community_talk.py new file mode 100644 index 00000000..bd9902eb --- /dev/null +++ b/community/community/doctype/community_talk/test_community_talk.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2021, Frappe and Contributors +# See license.txt +from __future__ import unicode_literals + +# import frappe +import unittest + +class TestCommunityTalk(unittest.TestCase): + pass diff --git a/community/community/web_form/__init__.py b/community/community/web_form/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/community/community/web_form/join_request/__init__.py b/community/community/web_form/join_request/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/community/community/web_form/join_request/join_request.js b/community/community/web_form/join_request/join_request.js new file mode 100644 index 00000000..699703c5 --- /dev/null +++ b/community/community/web_form/join_request/join_request.js @@ -0,0 +1,3 @@ +frappe.ready(function() { + // bind events here +}) \ No newline at end of file diff --git a/community/community/web_form/join_request/join_request.json b/community/community/web_form/join_request/join_request.json new file mode 100644 index 00000000..16512e81 --- /dev/null +++ b/community/community/web_form/join_request/join_request.json @@ -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-02-17 13:50:35.153793", + "modified_by": "Administrator", + "module": "Community", + "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 + } + ] +} \ No newline at end of file diff --git a/community/community/web_form/join_request/join_request.py b/community/community/web_form/join_request/join_request.py new file mode 100644 index 00000000..2334f8b2 --- /dev/null +++ b/community/community/web_form/join_request/join_request.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +import frappe + +def get_context(context): + # do your magic here + pass diff --git a/community/community/web_form/project_update/__init__.py b/community/community/web_form/project_update/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/community/community/web_form/project_update/project_update.js b/community/community/web_form/project_update/project_update.js new file mode 100644 index 00000000..35010cf7 --- /dev/null +++ b/community/community/web_form/project_update/project_update.js @@ -0,0 +1,8 @@ +frappe.ready(function () { + // bind events here + frappe.web_form.success_url = `hackathons/project?project=${frappe.utils.get_url_arg('project')}&hackathon=${frappe.utils.get_url_arg('hackathon')}`; + + $('.breadcrumb-container') + .html(`Back to my project`) + .addClass('py-4'); +}) \ No newline at end of file diff --git a/community/community/web_form/project_update/project_update.json b/community/community/web_form/project_update/project_update.json new file mode 100644 index 00000000..7a3929f3 --- /dev/null +++ b/community/community/web_form/project_update/project_update.json @@ -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-02-18 13:23:41.023545", + "modified_by": "Administrator", + "module": "Community", + "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 + } + ] +} \ No newline at end of file diff --git a/community/community/web_form/project_update/project_update.py b/community/community/web_form/project_update/project_update.py new file mode 100644 index 00000000..2334f8b2 --- /dev/null +++ b/community/community/web_form/project_update/project_update.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +import frappe + +def get_context(context): + # do your magic here + pass diff --git a/community/community/web_template/__init__.py b/community/community/web_template/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/community/www/hackathons/hackathon.html b/community/www/hackathons/hackathon.html index 1abb6f3c..7f15a18d 100644 --- a/community/www/hackathons/hackathon.html +++ b/community/www/hackathons/hackathon.html @@ -2,6 +2,8 @@ {% block title %}{{ hackathon }}{% endblock %} {% from "www/hackathons/macros/hero.html" import hero %} {% from "www/hackathons/macros/card.html" import null_card %} +{% from "www/hackathons/macros/navbar.html" import navbar %} +{% from "www/hackathons/macros/user.html" import show_user %} {% block head_include %} {% endblock %} -{% macro show_user(user) %} - {{ frappe.db.get_value("User", user, "full_name") }} -{% endmacro %} {% block content %}
@@ -68,7 +66,7 @@ {% if project.video_link %} Video ▶️ {% endif %} - +