feat: set default provider icons
This commit is contained in:
parent
611bb79c4f
commit
4a88848497
4 changed files with 29 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"actions": [],
|
||||
"allow_import": 1,
|
||||
"creation": "2017-11-18 15:36:09.676722",
|
||||
"doctype": "DocType",
|
||||
|
|
@ -82,6 +83,7 @@
|
|||
"label": "Identity Details"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!['Facebook', 'Frappe', 'Github', 'Google', 'Office 365'].includes(doc.social_login_provider)",
|
||||
"fieldname": "icon",
|
||||
"fieldtype": "Data",
|
||||
"label": "Icon"
|
||||
|
|
@ -157,7 +159,9 @@
|
|||
"label": "User ID Property"
|
||||
}
|
||||
],
|
||||
"modified": "2019-12-03 13:13:46.989099",
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2020-09-30 13:40:57.597276",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Integrations",
|
||||
"name": "Social Login Key",
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class SocialLoginKey(Document):
|
|||
self.name = frappe.scrub(self.provider_name)
|
||||
|
||||
def validate(self):
|
||||
self.set_icon()
|
||||
if self.custom_base_url and not self.base_url:
|
||||
frappe.throw(_("Please enter Base URL"), exc=BaseUrlNotSetError)
|
||||
if not self.authorize_url:
|
||||
|
|
@ -33,6 +34,19 @@ class SocialLoginKey(Document):
|
|||
if self.enable_social_login and not self.client_secret:
|
||||
frappe.throw(_("Please enter Client Secret before social login is enabled"), exc=ClientSecretNotSetError)
|
||||
|
||||
def set_icon(self):
|
||||
icon_map = {
|
||||
"Google": "google.svg",
|
||||
"Frappe": "frappe.svg",
|
||||
"Facebook": "facebook.svg",
|
||||
"Office 365": "office_365.svg",
|
||||
"GitHub": "github.svg"
|
||||
}
|
||||
|
||||
if self.provider_name in icon_map:
|
||||
icon_file = icon_map[self.provider_name]
|
||||
self.icon = '/assets/frappe/icons/social/{0}'.format(icon_file)
|
||||
|
||||
def get_social_login_provider(self, provider, initialize=False):
|
||||
providers = {}
|
||||
|
||||
|
|
|
|||
|
|
@ -304,3 +304,4 @@ frappe.patches.v13_0.increase_password_length
|
|||
frappe.patches.v13_0.add_toggle_width_in_navbar_settings
|
||||
frappe.patches.v13_0.rename_notification_fields
|
||||
frappe.patches.v13_0.remove_duplicate_navbar_items
|
||||
frappe.patches.v13_0.set_social_icons
|
||||
9
frappe/patches/v13_0/set_social_icons.py
Normal file
9
frappe/patches/v13_0/set_social_icons.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import frappe
|
||||
|
||||
def execute():
|
||||
providers = frappe.get_all("Social Login Key")
|
||||
|
||||
for provider in providers:
|
||||
doc = frappe.get_doc("Social Login Key", provider)
|
||||
doc.set_icon()
|
||||
doc.save()
|
||||
Loading…
Add table
Reference in a new issue