瀏覽代碼

Website Group related fixes

version-14
Anand Doshi 11 年之前
父節點
當前提交
ae3d88791d
共有 5 個檔案被更改,包括 36 行新增7 行删除
  1. +10
    -1
      webnotes/core/doctype/profile/profile.py
  2. +1
    -0
      webnotes/hooks.txt
  3. +6
    -1
      webnotes/templates/base.html
  4. +4
    -1
      webnotes/templates/generators/website_group.py
  5. +15
    -4
      webnotes/webutils.py

+ 10
- 1
webnotes/core/doctype/profile/profile.py 查看文件

@@ -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


+ 1
- 0
webnotes/hooks.txt 查看文件

@@ -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



+ 6
- 1
webnotes/templates/base.html 查看文件

@@ -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">


+ 4
- 1
webnotes/templates/generators/website_group.py 查看文件

@@ -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)

+ 15
- 4
webnotes/webutils.py 查看文件

@@ -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…
取消
儲存