diff --git a/frappe/config/setup.py b/frappe/config/setup.py
index de810f221b..85042052f5 100644
--- a/frappe/config/setup.py
+++ b/frappe/config/setup.py
@@ -1,4 +1,5 @@
from frappe import _
+from frappe.widgets.moduleview import add_setup_section
data = [
{
@@ -28,7 +29,7 @@ data = [
"label": _("User Permission Restrictions"),
"icon": "icon-user",
"description": _("Set Defaults and Restrictions for Users")
- }
+ },
]
},
{
@@ -132,6 +133,11 @@ data = [
"description": _("Install Applications."),
"icon": "icon-download"
},
+ {
+ "type": "doctype",
+ "name": "Social Login Keys",
+ "description": _("Enter keys to enable login via Facebook, Google, GitHub."),
+ },
{
"type": "doctype",
"name": "Backup Manager",
@@ -144,4 +150,9 @@ data = [
},
]
}
-]
\ No newline at end of file
+]
+
+def get_data():
+ out = list(data)
+ add_setup_section(out, "frappe", "website", _("Website"), "icon-globe")
+ return out
\ No newline at end of file
diff --git a/frappe/config/website.py b/frappe/config/website.py
new file mode 100644
index 0000000000..062747405d
--- /dev/null
+++ b/frappe/config/website.py
@@ -0,0 +1,93 @@
+from frappe import _
+
+data = [
+ {
+ "label": _("Documents"),
+ "icon": "icon-star",
+ "items": [
+ {
+ "type": "doctype",
+ "name": "Web Page",
+ "description": _("Content web page."),
+ },
+ {
+ "type": "doctype",
+ "name": "Blog Post",
+ "description": _("Single Post (article)."),
+ },
+ {
+ "type": "doctype",
+ "name": "Blogger",
+ "description": _("Profile of a blog writer."),
+ },
+ {
+ "type": "doctype",
+ "name": "Website Group",
+ "description": _("Web Site Forum Page."),
+ },
+ {
+ "type": "doctype",
+ "name": "Post",
+ "description": _("List of Web Site Forum's Posts."),
+ },
+ {
+ "type": "doctype",
+ "name": "Website Slideshow",
+ "description": _("Embed image slideshows in website pages."),
+ },
+ ]
+ },
+ {
+ "label": _("Setup"),
+ "icon": "icon-cog",
+ "items": [
+ {
+ "type": "doctype",
+ "name": "Website Settings",
+ "description": _("Setup of top navigation bar, footer and logo."),
+ },
+ {
+ "type": "page",
+ "name":"sitemap-browser",
+ "label": _("Sitemap Browser"),
+ "description": _("View or manage Website Route tree."),
+ "icon": "icon-sitemap"
+ },
+ {
+ "type": "doctype",
+ "name": "Style Settings",
+ "description": _("Setup of fonts and background."),
+ },
+ {
+ "type": "doctype",
+ "name": "Website Script",
+ "description": _("Javascript to append to the head section of the page."),
+ },
+ {
+ "type": "doctype",
+ "name": "Blog Settings",
+ "description": _("Write titles and introductions to your blog."),
+ },
+ {
+ "type": "doctype",
+ "name": "Blog Category",
+ "description": _("Categorize blog posts."),
+ },
+ {
+ "type": "doctype",
+ "name": "About Us Settings",
+ "description": _("Settings for About Us Page."),
+ },
+ {
+ "type": "doctype",
+ "name": "Contact Us Settings",
+ "description": _("Settings for Contact Us Page."),
+ },
+ {
+ "type": "doctype",
+ "name": "Website Page Permission",
+ "description": _("Define read, write, admin permissions for a Website Page."),
+ },
+ ]
+ },
+]
\ No newline at end of file
diff --git a/frappe/core/doctype/social_login_keys/__init__.py b/frappe/core/doctype/social_login_keys/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/frappe/core/doctype/social_login_keys/social_login_keys.py b/frappe/core/doctype/social_login_keys/social_login_keys.py
new file mode 100644
index 0000000000..cb42e2eea2
--- /dev/null
+++ b/frappe/core/doctype/social_login_keys/social_login_keys.py
@@ -0,0 +1,11 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# MIT License. See license.txt
+
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+class DocType:
+ def __init__(self, d, dl):
+ self.doc, self.doclist = d, dl
\ No newline at end of file
diff --git a/frappe/core/doctype/social_login_keys/social_login_keys.txt b/frappe/core/doctype/social_login_keys/social_login_keys.txt
new file mode 100644
index 0000000000..cffedba804
--- /dev/null
+++ b/frappe/core/doctype/social_login_keys/social_login_keys.txt
@@ -0,0 +1,98 @@
+[
+ {
+ "creation": "2014-03-04 08:29:52",
+ "docstatus": 0,
+ "modified": "2014-03-04 08:47:32",
+ "modified_by": "Administrator",
+ "owner": "Administrator"
+ },
+ {
+ "doctype": "DocType",
+ "document_type": "System",
+ "icon": "icon-signin",
+ "issingle": 1,
+ "module": "Core",
+ "name": "__common__"
+ },
+ {
+ "doctype": "DocField",
+ "name": "__common__",
+ "parent": "Social Login Keys",
+ "parentfield": "fields",
+ "parenttype": "DocType",
+ "permlevel": 0
+ },
+ {
+ "create": 1,
+ "doctype": "DocPerm",
+ "name": "__common__",
+ "parent": "Social Login Keys",
+ "parentfield": "permissions",
+ "parenttype": "DocType",
+ "permlevel": 0,
+ "read": 1,
+ "role": "System Manager",
+ "write": 1
+ },
+ {
+ "doctype": "DocType",
+ "name": "Social Login Keys"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "facebook",
+ "fieldtype": "Section Break",
+ "label": "Facebook"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "facebook_client_id",
+ "fieldtype": "Data",
+ "label": "Facebook Client ID"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "facebook_client_secret",
+ "fieldtype": "Data",
+ "label": "Facebook Client Secret"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "google",
+ "fieldtype": "Section Break",
+ "label": "Google"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "google_client_id",
+ "fieldtype": "Data",
+ "label": "Google Client ID"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "google_client_secret",
+ "fieldtype": "Data",
+ "label": "Google Client Secret"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "github",
+ "fieldtype": "Section Break",
+ "label": "GitHub"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "github_client_id",
+ "fieldtype": "Data",
+ "label": "GitHub Client ID"
+ },
+ {
+ "doctype": "DocField",
+ "fieldname": "github_client_secret",
+ "fieldtype": "Data",
+ "label": "GitHub Client Secret"
+ },
+ {
+ "doctype": "DocPerm"
+ }
+]
\ No newline at end of file
diff --git a/frappe/data/sample_site_config.json b/frappe/data/sample_site_config.json
index 93f4d07147..5d6082dc3c 100644
--- a/frappe/data/sample_site_config.json
+++ b/frappe/data/sample_site_config.json
@@ -15,15 +15,15 @@
"use_ssl": 0,
"auto_email_id": "hello@example.com",
- "google_sign_in": {
+ "google_login": {
"client_id": "google_client_id",
"client_secret": "google_client_secret"
},
- "github_sign_in": {
+ "github_login": {
"client_id": "github_client_id",
"client_secret": "github_client_secret"
},
- "facebook_sign_in": {
+ "facebook_login": {
"client_id": "facebook_client_id",
"client_secret": "facebook_client_secret"
}
diff --git a/frappe/templates/pages/login.html b/frappe/templates/pages/login.html
index 4325a195f0..d57871f75d 100644
--- a/frappe/templates/pages/login.html
+++ b/frappe/templates/pages/login.html
@@ -13,21 +13,21 @@
-->
- {%- if third_party_sign_in -%}
+ {%- if social_login -%}
or login via
- {%- if facebook_sign_in is defined %} - + {%- if facebook_login is defined %} + {{ _("Facebook") }} {%- endif -%} - {%- if google_sign_in is defined %} - + {%- if google_login is defined %} + {{ _("Google") }} {%- endif -%} - {%- if github_sign_in is defined %} - + {%- if github_login is defined %} + {{ _("GitHub") }} {%- endif -%}
diff --git a/frappe/templates/pages/login.py b/frappe/templates/pages/login.py index 3d9aa05968..210d8a1a14 100644 --- a/frappe/templates/pages/login.py +++ b/frappe/templates/pages/login.py @@ -16,8 +16,8 @@ def get_context(context): for provider in ("google", "github", "facebook"): if get_oauth_keys(provider): - context["{provider}_sign_in".format(provider=provider)] = get_oauth2_authorize_url(provider) - context["third_party_sign_in"] = True + context["{provider}_login".format(provider=provider)] = get_oauth2_authorize_url(provider) + context["social_login"] = True return context @@ -77,8 +77,23 @@ oauth2_providers = { } def get_oauth_keys(provider): - # get client_id and client_secret from conf - return frappe.conf.get("{provider}_sign_in".format(provider=provider)) + """get client_id and client_secret from database or conf""" + + # try conf + keys = frappe.conf.get("{provider}_login".format(provider=provider)) + + if not keys: + # try database + social = frappe.doc("Social Login Keys", "Social Login Keys") + keys = {} + for fieldname in ("client_id", "client_secret"): + value = social.fields.get("{provider}_{fieldname}".format(provider=provider, fieldname=fieldname)) + if not value: + keys = {} + break + keys[fieldname] = value + + return keys def get_oauth2_authorize_url(provider): flow = get_oauth2_flow(provider) diff --git a/frappe/website/doctype/website_group/website_group.py b/frappe/website/doctype/website_group/website_group.py index c31c8b1ab6..3068d3984f 100644 --- a/frappe/website/doctype/website_group/website_group.py +++ b/frappe/website/doctype/website_group/website_group.py @@ -19,4 +19,4 @@ class DocType(WebsiteGenerator): clear_cache(website_group=self.doc.name) def after_insert(self): - clear_cache(path=self.doc.parent_website_route) \ No newline at end of file + clear_cache(path=self.doc.parent_website_route) diff --git a/frappe/website/doctype/website_group/website_group.txt b/frappe/website/doctype/website_group/website_group.txt index 3df79e882c..65e4942638 100644 --- a/frappe/website/doctype/website_group/website_group.txt +++ b/frappe/website/doctype/website_group/website_group.txt @@ -2,7 +2,7 @@ { "creation": "2014-01-29 15:57:42", "docstatus": 0, - "modified": "2014-03-03 14:52:19", + "modified": "2014-03-04 09:36:30", "modified_by": "Administrator", "owner": "Administrator" }, @@ -22,6 +22,7 @@ "permlevel": 0 }, { + "cancel": 0, "create": 1, "delete": 1, "doctype": "DocPerm", diff --git a/frappe/widgets/moduleview.py b/frappe/widgets/moduleview.py index d242221498..27b119de28 100644 --- a/frappe/widgets/moduleview.py +++ b/frappe/widgets/moduleview.py @@ -73,6 +73,24 @@ def build_standard_config(module): def get_config(app, module): config = frappe.get_module("{app}.config.{module}".format(app=app, module=module)) return config.get_data() if hasattr(config, "get_data") else config.data + +def add_setup_section(config, app, module, label, icon): + try: + setup_section = get_setup_section(app, module, label, icon) + if setup_section: + config.append(setup_section) + except ImportError: + pass + +def get_setup_section(app, module, label, icon): + config = get_config(app, module) + for section in config: + if section.get("label")==_("Setup"): + return { + "label": label, + "icon": icon, + "items": section["items"] + } def get_doctypes(data): doctypes = []