Compare commits
1 Commits
rename-app
...
widgets
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5feeb4ca0c |
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
||||||
34
.github/workflows/ci.yml
vendored
34
.github/workflows/ci.yml
vendored
@@ -36,43 +36,25 @@ jobs:
|
|||||||
- name: setup node
|
- name: setup node
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: '14'
|
node-version: '12'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
- name: setup cache for bench
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ~/bench-cache
|
|
||||||
key: ${{ runner.os }}
|
|
||||||
- name: install bench
|
- name: install bench
|
||||||
run: |
|
run: pip3 install frappe-bench
|
||||||
pip3 install frappe-bench
|
|
||||||
which bench
|
|
||||||
- name: bench init
|
- name: bench init
|
||||||
run: |
|
run: bench init ~/frappe-bench --skip-redis-config-generation
|
||||||
if [ -d ~/bench-cache/bench.tgz ]
|
- name: add community app to bench
|
||||||
then
|
|
||||||
(cd && tar xzf ~/bench-cache/bench.tgz)
|
|
||||||
else
|
|
||||||
bench init ~/frappe-bench --skip-redis-config-generation --skip-assets --python "$(which python)"
|
|
||||||
mkdir -p ~/bench-cache
|
|
||||||
(cd && tar czf ~/bench-cache/bench.tgz frappe-bench)
|
|
||||||
fi
|
|
||||||
- name: add school app to bench
|
|
||||||
working-directory: /home/runner/frappe-bench
|
working-directory: /home/runner/frappe-bench
|
||||||
run: bench get-app school $GITHUB_WORKSPACE
|
run: bench get-app community $GITHUB_WORKSPACE
|
||||||
- name: create bench site
|
- name: create bench site
|
||||||
working-directory: /home/runner/frappe-bench
|
working-directory: /home/runner/frappe-bench
|
||||||
run: bench new-site --mariadb-root-password root --admin-password admin frappe.local
|
run: bench new-site --mariadb-root-password root --admin-password admin frappe.local
|
||||||
- name: install school app
|
- name: install community app
|
||||||
working-directory: /home/runner/frappe-bench
|
working-directory: /home/runner/frappe-bench
|
||||||
run: bench --verbose --site frappe.local install-app school
|
run: bench --site frappe.local install-app community
|
||||||
- name: allow tests
|
- name: allow tests
|
||||||
working-directory: /home/runner/frappe-bench
|
working-directory: /home/runner/frappe-bench
|
||||||
run: bench --site frappe.local set-config allow_tests true
|
run: bench --site frappe.local set-config allow_tests true
|
||||||
- name: bench build
|
|
||||||
working-directory: /home/runner/frappe-bench
|
|
||||||
run: bench --site frappe.local build
|
|
||||||
- name: run tests
|
- name: run tests
|
||||||
working-directory: /home/runner/frappe-bench
|
working-directory: /home/runner/frappe-bench
|
||||||
run: bench --site frappe.local run-tests --app school
|
run: bench --site frappe.local run-tests --app community
|
||||||
|
|
||||||
|
|||||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -3,8 +3,4 @@
|
|||||||
*.egg-info
|
*.egg-info
|
||||||
*.swp
|
*.swp
|
||||||
tags
|
tags
|
||||||
school/docs/current
|
community/docs/current
|
||||||
school/public/dist
|
|
||||||
__pycache__/
|
|
||||||
*.py[cod]
|
|
||||||
*$py.class
|
|
||||||
24
MANIFEST.in
24
MANIFEST.in
@@ -4,15 +4,15 @@ include *.json
|
|||||||
include *.md
|
include *.md
|
||||||
include *.py
|
include *.py
|
||||||
include *.txt
|
include *.txt
|
||||||
recursive-include school *.css
|
recursive-include community *.css
|
||||||
recursive-include school *.csv
|
recursive-include community *.csv
|
||||||
recursive-include school *.html
|
recursive-include community *.html
|
||||||
recursive-include school *.ico
|
recursive-include community *.ico
|
||||||
recursive-include school *.js
|
recursive-include community *.js
|
||||||
recursive-include school *.json
|
recursive-include community *.json
|
||||||
recursive-include school *.md
|
recursive-include community *.md
|
||||||
recursive-include school *.png
|
recursive-include community *.png
|
||||||
recursive-include school *.py
|
recursive-include community *.py
|
||||||
recursive-include school *.svg
|
recursive-include community *.svg
|
||||||
recursive-include school *.txt
|
recursive-include community *.txt
|
||||||
recursive-exclude school *.pyc
|
recursive-exclude community *.pyc
|
||||||
64
README.md
64
README.md
@@ -1,4 +1,4 @@
|
|||||||
## School
|
## Community
|
||||||
|
|
||||||
This app helps people organize and manage their own communities.
|
This app helps people organize and manage their own communities.
|
||||||
|
|
||||||
@@ -7,67 +7,23 @@ The App has following components:
|
|||||||
1. Hackathons
|
1. Hackathons
|
||||||
1. LMS
|
1. LMS
|
||||||
|
|
||||||
School is built on the [Frappe Framework](https://github.com/frappe/frappe), a full-stack web app framework built with Python & JavaScript.
|
Community is built on the [Frappe Framework](https://github.com/frappe/frappe), a full-stack web app framework built with Python & JavaScript.
|
||||||
|
|
||||||
## Development Setup
|
### Local Setup
|
||||||
|
|
||||||
**Step 1:** Clone the repo
|
|
||||||
|
|
||||||
```
|
|
||||||
$ git clone https://github.com/frappe/school.git
|
|
||||||
|
|
||||||
$ cd school
|
|
||||||
```
|
|
||||||
|
|
||||||
**Step 2:** Run docker-compose
|
|
||||||
|
|
||||||
```
|
|
||||||
$ docker-compose up
|
|
||||||
```
|
|
||||||
|
|
||||||
**Step 3:** Visit the website at http://localhost:8000/
|
|
||||||
|
|
||||||
You'll have to go through the setup wizard to setup the website for the first time you access it. Login using the following credentiasl to complete the setup wizard.
|
|
||||||
|
|
||||||
```
|
|
||||||
Username: Administrator
|
|
||||||
password: admin
|
|
||||||
```
|
|
||||||
|
|
||||||
TODO: Explain how to load sample data
|
|
||||||
|
|
||||||
## Stopping the server
|
|
||||||
|
|
||||||
Press `ctrl+c` in the terminal to stop the server. You can also run `docker-compose down` in another terminal to stop it.
|
|
||||||
|
|
||||||
To completely reset the instance, do the following:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ docker-compose down --volumes
|
|
||||||
$ docker-compose up
|
|
||||||
```
|
|
||||||
|
|
||||||
## Making Code Changes
|
|
||||||
|
|
||||||
The dev setup is configured to reload whenever any code is changed. Just edit the code and reload the webpage.
|
|
||||||
|
|
||||||
Commit the changes in a branch and send a pull request.
|
|
||||||
|
|
||||||
## Local Setup - The Hard Way
|
|
||||||
|
|
||||||
To setup the repository locally follow the steps mentioned below:
|
To setup the repository locally follow the steps mentioned below:
|
||||||
|
|
||||||
1. Install bench and setup a frappe-bench directory by following the [Installation Steps](https://frappeframework.com/docs/user/en/installation).
|
1. Install bench and setup a frappe-bench directory by following the [Installation Steps](https://frappeframework.com/docs/user/en/installation).
|
||||||
1. Start the server by running bench start.
|
1. Start the server by running bench start.
|
||||||
1. In a separate terminal window, create a new site by running bench new-site school.test.
|
1. In a separate terminal window, create a new site by running bench new-site community.test.
|
||||||
1. Run bench get-app https://github.com/frappe/school.
|
1. Run bench get-app https://github.com/fossunited/community.
|
||||||
1. Run bench --site school.test install-app school.
|
1. Run bench --site community.test install-app community.
|
||||||
1. Map your site to localhost with the command ```bench --site school.test add-to-hosts```
|
1. Map your site to localhost with the command ```bench --site community.test add-to-hosts```
|
||||||
1. Now open the URL http://school.test:8000/ in your browser, you should see the app running.
|
1. Now open the URL http://community.test:8000/docs in your browser, you should see the app running.
|
||||||
|
|
||||||
### Contribution Guidelines (for The Hard Way)
|
### Contribution Guidelines
|
||||||
|
|
||||||
1. Go to the apps/school directory of your installation and execute git pull --unshallow to ensure that you have the full git repository. Also fork the frappe/school repository on GitHub.
|
1. Go to the apps/community directory of your installation and execute git pull --unshallow to ensure that you have the full git repository. Also fork the fossunited/community repository on GitHub.
|
||||||
1. Check out a working branch in git (e.g. git checkout -b my-new-branch).
|
1. Check out a working branch in git (e.g. git checkout -b my-new-branch).
|
||||||
1. Make your proposed changes to the source
|
1. Make your proposed changes to the source
|
||||||
1. Run your local version (e.g. bench start in your bench installation). Make sure that your changes work the way you want them to.
|
1. Run your local version (e.g. bench start in your bench installation). Make sure that your changes work the way you want them to.
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2021, Frappe and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('Community Course Member', {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"autoname": "field:user_name",
|
||||||
|
"creation": "2021-03-02 11:24:49.612530",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"enabled",
|
||||||
|
"full_name",
|
||||||
|
"user_name",
|
||||||
|
"email",
|
||||||
|
"short_intro",
|
||||||
|
"bio",
|
||||||
|
"photo",
|
||||||
|
"route"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "enabled",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Enabled"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "full_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Full Name",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "user_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "User Name",
|
||||||
|
"reqd": 1,
|
||||||
|
"unique": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "email",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Email",
|
||||||
|
"options": "Email",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "short_intro",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Short Intro"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "bio",
|
||||||
|
"fieldtype": "Markdown Editor",
|
||||||
|
"label": "Bio"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "photo",
|
||||||
|
"fieldtype": "Attach Image",
|
||||||
|
"label": "Photo"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "route",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Route"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"has_web_view": 1,
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"is_published_field": "enabled",
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-04-06 11:50:41.551665",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Community",
|
||||||
|
"name": "Community Course Member",
|
||||||
|
"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,
|
||||||
|
"route": "community-course-member",
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2021, Frappe and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
import re
|
||||||
|
from frappe.website.website_generator import WebsiteGenerator
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
|
class CommunityCourseMember(WebsiteGenerator):
|
||||||
|
|
||||||
|
def get_context(self, context):
|
||||||
|
context.abbr = ("").join([ s[0] for s in self.full_name.split() ])
|
||||||
|
return context
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
self.validate_user_name()
|
||||||
|
if not self.route:
|
||||||
|
self.route = self.user_name
|
||||||
|
|
||||||
|
def validate_user_name(self):
|
||||||
|
if len(self.user_name) < 4:
|
||||||
|
frappe.throw(_("Username must be atleast 4 characters long."))
|
||||||
|
if not re.match("^[A-Za-z0-9_]*$", self.user_name):
|
||||||
|
frappe.throw(_("Username can only contain alphabets, numbers, and underscore."))
|
||||||
|
self.user_name = self.user_name.lower()
|
||||||
|
|
||||||
|
def after_insert(self):
|
||||||
|
if frappe.db.exists("User", self.email):
|
||||||
|
user = frappe.get_doc("User", self.email)
|
||||||
|
else:
|
||||||
|
user, update_password_link = self.create_user()
|
||||||
|
self.send_email(update_password_link)
|
||||||
|
|
||||||
|
def send_email(self, update_password_link):
|
||||||
|
|
||||||
|
args = {
|
||||||
|
'update_password_link': update_password_link,
|
||||||
|
'full_name': self.full_name,
|
||||||
|
}
|
||||||
|
|
||||||
|
frappe.sendmail(
|
||||||
|
recipients=self.email,
|
||||||
|
sender="Administrator",
|
||||||
|
subject=_("Set your Password"),
|
||||||
|
template="community_course_membership",
|
||||||
|
reference_doctype=self.doctype,
|
||||||
|
reference_name=self.name,
|
||||||
|
send_priority=0,
|
||||||
|
queue_separately=True,
|
||||||
|
args=args)
|
||||||
|
|
||||||
|
def create_user(self):
|
||||||
|
user = frappe.get_doc({
|
||||||
|
"doctype": "User",
|
||||||
|
"email": self.email,
|
||||||
|
"first_name": self.full_name.split(" ")[0],
|
||||||
|
"full_name": self.full_name,
|
||||||
|
"username": self.user_name,
|
||||||
|
"send_welcome_email": 0,
|
||||||
|
"user_type": 'Website User',
|
||||||
|
"redirect_url": self.name
|
||||||
|
})
|
||||||
|
user.save(ignore_permissions=True)
|
||||||
|
update_password_link = user.reset_password()
|
||||||
|
return user, update_password_link
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{% extends "templates/web.html" %}
|
||||||
|
{% block page_content %}
|
||||||
|
<div class="py-20 row">
|
||||||
|
{% if photo %}
|
||||||
|
<div class="col-sm-2 border border-dark">
|
||||||
|
<img src="{{ photo }}" alt="{{ full_name }}">
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<div class="standard-image" style="font-size: 30px;">{{ abbr }}</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="col">
|
||||||
|
<h1>{{ full_name }}</h1>
|
||||||
|
{% if short_intro %}
|
||||||
|
<p class="lead"> {{ short_intro }} </p>
|
||||||
|
{% endif %}
|
||||||
|
{% if bio %}
|
||||||
|
<p class="markdown-style"> {{ frappe.utils.md_to_html(bio) }} </p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
<!-- this is a sample default web page template -->
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<div>
|
||||||
|
<a href="{{ doc.route }}">{{ doc.full_name }}</a>
|
||||||
|
</div>
|
||||||
|
<!-- this is a sample default list template -->
|
||||||
@@ -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 TestCommunityCourseMember(unittest.TestCase):
|
||||||
|
pass
|
||||||
@@ -13,13 +13,13 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Member",
|
"label": "Member",
|
||||||
"options": "User"
|
"options": "Community Member"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-05-21 12:15:51.286478",
|
"modified": "2021-02-15 12:03:31.153575",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Community",
|
"module": "Community",
|
||||||
"name": "Community Event Volunteer",
|
"name": "Community Event Volunteer",
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2021, Frappe and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('Community Member', {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_guest_to_view": 1,
|
||||||
|
"allow_rename": 1,
|
||||||
|
"creation": "2021-02-12 15:47:23.591567",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"full_name",
|
||||||
|
"email",
|
||||||
|
"enabled",
|
||||||
|
"column_break_4",
|
||||||
|
"role",
|
||||||
|
"short_intro",
|
||||||
|
"section_break_7",
|
||||||
|
"bio",
|
||||||
|
"section_break_9",
|
||||||
|
"username",
|
||||||
|
"photo",
|
||||||
|
"column_break_12",
|
||||||
|
"email_preference",
|
||||||
|
"route",
|
||||||
|
"abbr"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "enabled",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Enabled"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "full_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Full Name",
|
||||||
|
"reqd": 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"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "short_intro",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Short Intro"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_in_quick_entry": 1,
|
||||||
|
"fieldname": "bio",
|
||||||
|
"fieldtype": "Markdown Editor",
|
||||||
|
"label": "Bio"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "route",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Route"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "email",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Email",
|
||||||
|
"options": "Email",
|
||||||
|
"reqd": 1,
|
||||||
|
"unique": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "username",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "User Name",
|
||||||
|
"unique": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "email_preference",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Email preference",
|
||||||
|
"options": "Email on every Message\nOne Digest Mail per day\nNever"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_4",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_7",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_9",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_12",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "abbr",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Abbr",
|
||||||
|
"read_only": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"has_web_view": 1,
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-04-16 10:22:46.837311",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Community",
|
||||||
|
"name": "Community Member",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "Website Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"quick_entry": 1,
|
||||||
|
"search_fields": "full_name",
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"title_field": "full_name",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# -*- 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.website.website_generator import WebsiteGenerator
|
||||||
|
import re
|
||||||
|
from frappe import _
|
||||||
|
from frappe.model.rename_doc import rename_doc
|
||||||
|
|
||||||
|
class CommunityMember(WebsiteGenerator):
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
self.validate_username()
|
||||||
|
self.abbr = ("").join([ s[0] for s in self.full_name.split() ])
|
||||||
|
if self.route != self.username:
|
||||||
|
self.route = self.username
|
||||||
|
|
||||||
|
def validate_username(self):
|
||||||
|
if self.username:
|
||||||
|
if len(self.username) < 4:
|
||||||
|
frappe.throw(_("Username must be atleast 4 characters long."))
|
||||||
|
if not re.match("^[A-Za-z0-9_]*$", self.username):
|
||||||
|
frappe.throw(_("Username can only contain alphabets, numbers and underscore."))
|
||||||
|
self.username = self.username.lower()
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<CommunityMember: {self.email}>"
|
||||||
|
|
||||||
|
def create_member_from_user(doc, method):
|
||||||
|
member = frappe.get_doc({
|
||||||
|
"doctype": "Community Member",
|
||||||
|
"full_name": doc.full_name,
|
||||||
|
"username": doc.username if len(doc.username) > 3 else ("").join([ s for s in doc.full_name.split() ]),
|
||||||
|
"email": doc.email,
|
||||||
|
"route": doc.username,
|
||||||
|
"owner": doc.email
|
||||||
|
})
|
||||||
|
member.save(ignore_permissions=True)
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{% extends "templates/web.html" %}
|
||||||
|
{% block page_content %}
|
||||||
|
<div class="py-20 row">
|
||||||
|
{% if photo %}
|
||||||
|
<div class="col-sm-2 border border-dark">
|
||||||
|
<img src="{{ photo }}" alt="{{ full_name }}">
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<div class="standard-image" style="font-size: 30px;">{{ abbr }}</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="col">
|
||||||
|
<h1>{{ full_name }}</h1>
|
||||||
|
{% if short_intro %}
|
||||||
|
<p class="lead"> {{ short_intro }} </p>
|
||||||
|
{% endif %}
|
||||||
|
{% if bio %}
|
||||||
|
<p class="markdown-style"> {{ frappe.utils.md_to_html(bio) }} </p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
<!-- this is a sample default web page template -->
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<div>
|
||||||
|
<a href="{{ doc.route }}">{{ doc.title or doc.name }}</a>
|
||||||
|
</div>
|
||||||
|
<!-- this is a sample default list template -->
|
||||||
@@ -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 TestCommunityMember(unittest.TestCase):
|
||||||
|
pass
|
||||||
17
community/community/utils.py
Normal file
17
community/community/utils.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
def create_members_from_users():
|
||||||
|
users = frappe.get_all("User", {"enabled": 1}, ["email"])
|
||||||
|
for user in users:
|
||||||
|
if not frappe.db.get_value("Community Member", {"email": user.email}, "name"):
|
||||||
|
doc = frappe.get_doc("User", {"email": user.email})
|
||||||
|
username = doc.username if doc.username and len(doc.username) > 3 else ("").join([ s for s in doc.full_name.split() ])
|
||||||
|
if not frappe.db.exists("Community Member", username):
|
||||||
|
print(doc.email, username)
|
||||||
|
member = frappe.new_doc("Community Member")
|
||||||
|
member.full_name = doc.full_name
|
||||||
|
member.username = username
|
||||||
|
member.email = doc.email
|
||||||
|
member.route = username
|
||||||
|
member.owner = doc.email
|
||||||
|
member.insert(ignore_permissions=True)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
frappe.ready(function() {
|
||||||
|
frappe.web_form.after_save = () => {
|
||||||
|
window.location.href = frappe.web_form.get_value("username")
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -2,47 +2,46 @@
|
|||||||
"accept_payment": 0,
|
"accept_payment": 0,
|
||||||
"allow_comments": 0,
|
"allow_comments": 0,
|
||||||
"allow_delete": 0,
|
"allow_delete": 0,
|
||||||
"allow_edit": 0,
|
"allow_edit": 1,
|
||||||
"allow_incomplete": 0,
|
"allow_incomplete": 0,
|
||||||
"allow_multiple": 0,
|
"allow_multiple": 0,
|
||||||
"allow_print": 0,
|
"allow_print": 0,
|
||||||
"amount": 0.0,
|
"amount": 0.0,
|
||||||
"amount_based_on_field": 0,
|
"amount_based_on_field": 0,
|
||||||
"apply_document_permissions": 0,
|
"apply_document_permissions": 0,
|
||||||
"button_label": "Submit",
|
"breadcrumbs": "",
|
||||||
"client_script": "",
|
"button_label": "Save",
|
||||||
"creation": "2021-08-19 15:16:22.341723",
|
"creation": "2021-03-09 17:34:03.394301",
|
||||||
"custom_css": "[data-doctype=\"Web Form\"] {\n max-width: 720px;\n margin: 6rem auto;\n}",
|
"doc_type": "Community Member",
|
||||||
"doc_type": "Talk",
|
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "Web Form",
|
"doctype": "Web Form",
|
||||||
"idx": 0,
|
"idx": 0,
|
||||||
"is_standard": 1,
|
"is_standard": 1,
|
||||||
"login_required": 1,
|
"login_required": 1,
|
||||||
"max_attachment_size": 0,
|
"max_attachment_size": 0,
|
||||||
"modified": "2021-08-24 19:57:06.806994",
|
"modified": "2021-03-22 12:04:22.571655",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Event Management",
|
"module": "Community",
|
||||||
"name": "purpose-a-talk",
|
"name": "update-profile",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"payment_button_label": "Buy Now",
|
"payment_button_label": "Buy Now",
|
||||||
"published": 1,
|
"published": 1,
|
||||||
"route": "propose-talk",
|
"route": "edit-profile",
|
||||||
"route_to_success_link": 0,
|
"route_to_success_link": 0,
|
||||||
"show_attachments": 0,
|
"show_attachments": 0,
|
||||||
"show_in_grid": 0,
|
"show_in_grid": 0,
|
||||||
"show_sidebar": 0,
|
"show_sidebar": 0,
|
||||||
"sidebar_items": [],
|
"sidebar_items": [],
|
||||||
"success_message": "Talk Submitted!",
|
"success_message": "Profile updated successfully.",
|
||||||
"success_url": "/purpose-a-talk",
|
"success_url": "/",
|
||||||
"title": "Propose a Talk",
|
"title": "Update Profile",
|
||||||
"web_form_fields": [
|
"web_form_fields": [
|
||||||
{
|
{
|
||||||
"allow_read_on_all_link_options": 0,
|
"allow_read_on_all_link_options": 0,
|
||||||
"fieldname": "title",
|
"fieldname": "full_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"label": "Title",
|
"label": "Full Name",
|
||||||
"max_length": 0,
|
"max_length": 0,
|
||||||
"max_value": 0,
|
"max_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
@@ -51,52 +50,51 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_read_on_all_link_options": 0,
|
"allow_read_on_all_link_options": 0,
|
||||||
"fieldname": "category",
|
"fieldname": "username",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"label": "Category",
|
"label": "User Name",
|
||||||
"max_length": 0,
|
|
||||||
"max_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"show_in_filter": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_read_on_all_link_options": 0,
|
|
||||||
"fieldname": "event",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 0,
|
|
||||||
"label": "Event",
|
|
||||||
"max_length": 0,
|
|
||||||
"max_value": 0,
|
|
||||||
"options": "Event Details",
|
|
||||||
"read_only": 1,
|
|
||||||
"reqd": 0,
|
|
||||||
"show_in_filter": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_read_on_all_link_options": 0,
|
|
||||||
"fieldname": "thumbnail",
|
|
||||||
"fieldtype": "Attach",
|
|
||||||
"hidden": 0,
|
|
||||||
"label": "Preview Image",
|
|
||||||
"max_length": 0,
|
|
||||||
"max_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"show_in_filter": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_read_on_all_link_options": 0,
|
|
||||||
"fieldname": "about",
|
|
||||||
"fieldtype": "Text Editor",
|
|
||||||
"hidden": 0,
|
|
||||||
"label": "About",
|
|
||||||
"max_length": 0,
|
"max_length": 0,
|
||||||
"max_value": 0,
|
"max_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"show_in_filter": 0
|
"show_in_filter": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_read_on_all_link_options": 0,
|
||||||
|
"fieldname": "short_intro",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Short Intro",
|
||||||
|
"max_length": 0,
|
||||||
|
"max_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"show_in_filter": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_read_on_all_link_options": 0,
|
||||||
|
"fieldname": "bio",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Bio",
|
||||||
|
"max_length": 0,
|
||||||
|
"max_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"show_in_filter": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_read_on_all_link_options": 0,
|
||||||
|
"fieldname": "photo",
|
||||||
|
"fieldtype": "Attach Image",
|
||||||
|
"hidden": 0,
|
||||||
|
"label": "Photo",
|
||||||
|
"max_length": 0,
|
||||||
|
"max_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"show_in_filter": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
"fieldname": "organizer",
|
"fieldname": "organizer",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Organizer",
|
"label": "Organizer",
|
||||||
"options": "User"
|
"options": "Community Member"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "year",
|
"fieldname": "year",
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-05-21 12:22:26.619776",
|
"modified": "2021-04-14 11:43:23.515972",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Hackathon",
|
"module": "Hackathon",
|
||||||
"name": "Community Hackathon",
|
"name": "Community Hackathon",
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user