Updated page view for Chapters list and Chapter single view.

This commit is contained in:
ashwinisave35
2017-05-10 16:59:11 +05:30
parent 4045f91cc6
commit 708e5afbc0
7 changed files with 186 additions and 45 deletions

View File

@@ -50,7 +50,7 @@
"collapsible": 0,
"columns": 0,
"fieldname": "chapter_head",
"fieldtype": "Data",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -61,6 +61,7 @@
"label": "Chapter Head",
"length": 0,
"no_copy": 0,
"options": "User",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@@ -103,6 +104,66 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "published",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Published",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "route",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Route",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@@ -133,6 +194,36 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "address",
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Address",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
@@ -170,8 +261,8 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "route",
"fieldtype": "Data",
"fieldname": "comments",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -179,39 +270,10 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Route",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "published",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Published",
"label": "Comments",
"length": 0,
"no_copy": 0,
"options": "Chapter Comments",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@@ -236,7 +298,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-05-08 17:05:38.056334",
"modified": "2017-05-10 16:33:43.490022",
"modified_by": "Administrator",
"module": "ERPNext Foundation",
"name": "Chapter",

View File

@@ -7,6 +7,8 @@ import frappe
from frappe.website.website_generator import WebsiteGenerator
class Chapter(WebsiteGenerator):
def get_context(self, context):
context.no_cache = True
pass
def get_list_context(context):

View File

@@ -2,8 +2,65 @@
{% block page_content %}
<h1>{{ title }}</h1>
<h3>Details</h3>
<p>{{ introduction }}</p>
<p><br><a href="/join-chapter?name={{ name }}" class='btn btn-primary'>Join this Chapter</a></p>
<h3>List of Members</h3>
{% if members %}
<table class="table table-bordered small" style="max-width: 400px;">
<tr>
<th>Member Name</th>
<th>Member Email</th>
</tr>
{% for user in members %}
<tr>
<td>{{ frappe.db.get_value('User', user.user, 'full_name') }}</td>
<td>{{ frappe.db.get_value('User', user.user, 'email') }}</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>No member yet.</p>
{% endif %}
<h3>Chapter Head</h3>
<table class="table table-bordered" style="max-width: 400px;">
<tr>
<td>Name</td>
<td>{{ frappe.db.get_value('User', chapter_head, 'full_name') }}</td>
</tr>
<tr>
<td>Email</td>
<td>{{ frappe.db.get_value('User', chapter_head, 'email') }}</td>
</tr>
<tr>
<td>Phone</td>
<td>{{ frappe.db.get_value('User', chapter_head, 'phone') }}</td>
</tr>
</table>
<h3>Address</h3>
<p>{{ address }}</p>
<p style="margin: 20px 0 30px;"><a href="/join-chapter?name={{ name }}" class='btn btn-primary'>Join this Chapter</a></p>
<div class="form-wrapper">
<div class="row">
<div class="col-lg-6">
<form method="post" action="/post-comments.html?name={{ name }}">
<div class="form-group">
<label for="name">Enter Name</label>
<input type="text" class="form-control" placeholder="Enter Name" name="name" value= "{{ frappe.session.user }}" />
</div>
<div class="form-group">
<label for="">Enter Comment</label>
<textarea class="form-control" placeholder="Enter your comment"></textarea>
</div>
<div class="filed-wrap"><button class="btn-primary btn" type="submit">Post comment</button></div>
</form>
</div>
</div>
</div>
{% endblock %}
<!-- this is a sample default web page template -->

View File

@@ -1,4 +1,17 @@
<div>
<a href={{ route }}>{{ title }} hosted by {{ chapter_head }}</a>
<div style="margin-bottom: 30px; max-width: 600px" class="with-border clickable">
<a href={{ route }}>
<h3>{{ doc.title }}</h3>
<p>
<span class="label">{{ frappe.db.get_value('User', chapter_head, 'full_name') }}</span>
<span class="label">
{% if members %}
Members: {{ members|length }}
{% else %}
Members: 0
{% endif %}
</span>
</p>
<p>{{ html2text(doc.introduction[:200]) }}{% if introduction|len > 200 %}...{% endif %}</p>
</a>
</div>
<!-- this is a sample default list template -->

View File

@@ -37,13 +37,14 @@ web_include_css = "/assets/foundation/css/style.css"
home_page = "index"
website_context = {
"navbar_search": 1,
# "navbar_search": 1,
"brand_html": "<img class='navbar-icon' src='/assets/foundation/img/erpnext-foundation-icon.svg' />ERPNext Foundation",
"copyright": "ERPNext Open Source Software Foundation",
"footer_address": "<br>ERPNext is and will always be 100% Open Source",
"top_bar_items": [
{"label": "Service Providers", "url": "/service-providers"},
{"label": "Jobs", "url": "/erpnext-jobs"},
{"label": "Chapters", "url": "/chapters"},
],
"footer_items": [
{"label": "Foundation", "child_items": [

View File

@@ -3,9 +3,13 @@
{% block page_content %}
{% if frappe.session.user=='Guest' %}
<p>Please signup and login to join this chapter</p>
<p><a href="/login" class='btn btn-primary'>Login</a></p>
<p><a href="/login?redirect-to=/{{ chapter.route }}" class='btn btn-primary'>Login</a></p>
{% else %}
{% if already_member %}
<p>You are already a member of {{ chapter.title }}!</p>
{% else %}
<p>Welcome to chapter {{ chapter.title }}!</p>
{% endif %}
<p><a href="/{{ chapter.route }}" class='btn btn-primary'>Go to Chapter Page</a></p>
{% endif %}

View File

@@ -1,12 +1,14 @@
import frappe
def get_context(context):
context.no_cache = True
chapter = frappe.get_doc('Chapter', frappe.form_dict.name)
if frappe.session.user!='Guest':
chapter = frappe.get_doc('Chapter', frappe.form_dict.name)
if frappe.session.user not in [d.user for d in chapter.members]:
if frappe.session.user in [d.user for d in chapter.members]:
context.already_member = True
else:
chapter.append('members', dict(user=frappe.session.user))
chapter.save()
chapter.save(ignore_permissions=1)
frappe.db.commit()
context.chapter = chapter
context.chapter = chapter