Website Group related fixes
This commit is contained in:
parent
375e89df95
commit
ae3d88791d
5 changed files with 36 additions and 7 deletions
|
|
@ -43,7 +43,7 @@ class DocType:
|
|||
pass # email server not set, don't send email
|
||||
|
||||
self.doc.new_password = ""
|
||||
|
||||
self.update_gravatar()
|
||||
|
||||
def check_enable_disable(self):
|
||||
# do not allow disabling administrator/guest
|
||||
|
|
@ -106,6 +106,15 @@ class DocType:
|
|||
# owner is always name
|
||||
webnotes.conn.set(self.doc, 'owner', self.doc.name)
|
||||
webnotes.clear_cache(user=self.doc.name)
|
||||
|
||||
def update_gravatar(self):
|
||||
import md5
|
||||
if not self.doc.user_image:
|
||||
if self.doc.fb_username:
|
||||
self.doc.user_image = "https://graph.facebook.com/" + self.doc.fb_username + "/picture"
|
||||
else:
|
||||
self.doc.user_image = "https://secure.gravatar.com/avatar/" + md5.md5(self.doc.name).hexdigest() \
|
||||
+ "?d=retro"
|
||||
|
||||
def reset_password(self):
|
||||
from webnotes.utils import random_string, get_url
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ scheduler_event = all:webnotes.utils.email_lib.bulk.flush
|
|||
scheduler_event = daily:webnotes.utils.email_lib.bulk.clear_outbox
|
||||
scheduler_event = daily:webnotes.core.doctype.notification_count.notification_count.delete_event_notification_count
|
||||
scheduler_event = daily:webnotes.core.doctype.event.event.send_event_digest
|
||||
scheduler_event = hourly:webnotes.templates.generator.website_group.clear_event_cache
|
||||
|
||||
on_session_creation = webnotes.auth.notify_administrator_login
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,12 @@
|
|||
<div class="container page-container" id="page-{{ name or page_name }}">
|
||||
<div class="row">
|
||||
<div class="col-sm-3 col-sm-push-9 page-sidebar hidden-xs" data-html-block="sidebar">
|
||||
{%- block sidebar -%}{%- if sidebar is defined -%}{{ sidebar }}{%- endif -%}{%- endblock -%}
|
||||
{%- block sidebar -%}
|
||||
{%- if sidebar is defined -%}
|
||||
{{ sidebar }}
|
||||
{{ private_pages or "" }}
|
||||
{%- endif -%}
|
||||
{%- endblock -%}
|
||||
</div>
|
||||
<div class="col-sm-9 col-sm-pull-3 page-content" data-html-block="content">
|
||||
<div class="text-right"><a class="visible-xs toggle-sidebar no-decoration">
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ def get_context(context):
|
|||
raise webnotes.PermissionError
|
||||
|
||||
group_context = get_group_context(group, view, bean)
|
||||
group_context["access"] = get_access(group)
|
||||
group_context.update(context)
|
||||
|
||||
return group_context
|
||||
|
|
@ -122,3 +121,7 @@ def clear_cache(page_name=None, website_group=None):
|
|||
for group in website_groups:
|
||||
for view in get_views(group.group_type):
|
||||
cache.delete_value("website_group_context:{}:{}".format(group.page_name, view))
|
||||
|
||||
def clear_event_cache():
|
||||
for group in webnotes.conn.sql_list("""select name from `tabWebsite Group` where group_type='Event'"""):
|
||||
clear_unit_views(website_group=group)
|
||||
|
|
|
|||
|
|
@ -91,13 +91,24 @@ def get_context(page_name):
|
|||
if can_cache():
|
||||
context = webnotes.cache().get_value(cache_key)
|
||||
|
||||
access = get_access(page_name)
|
||||
if not context:
|
||||
sitemap_options = get_sitemap_options(page_name)
|
||||
context = build_context(sitemap_options)
|
||||
context = get_sitemap_options(page_name)
|
||||
|
||||
# permission may be required for rendering
|
||||
context["access"] = access
|
||||
|
||||
context = build_context(context)
|
||||
|
||||
if can_cache(context.no_cache):
|
||||
del context["access"]
|
||||
webnotes.cache().set_value(cache_key, context)
|
||||
|
||||
context["access"] = access
|
||||
context.update(context.data or {})
|
||||
|
||||
# TODO private pages
|
||||
|
||||
return context
|
||||
|
||||
def get_sitemap_options(page_name):
|
||||
|
|
@ -137,8 +148,8 @@ def build_sitemap_options(page_name):
|
|||
where lft < %s and rgt > %s order by lft asc""", (sitemap_options.lft, sitemap_options.rgt), as_dict=True)
|
||||
|
||||
sitemap_options.children = webnotes.conn.sql("""select * from `tabWebsite Sitemap`
|
||||
where parent_website_sitemap=%s""", (sitemap_options.page_name,), as_dict=True)
|
||||
|
||||
where parent_website_sitemap=%s and public_read=1""", (sitemap_options.page_name,), as_dict=True)
|
||||
|
||||
# determine templates to be used
|
||||
if not sitemap_options.base_template_path:
|
||||
sitemap_options.base_template_path = "templates/base.html"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue