Skip to content

Commit

Permalink
Update to v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
kid1194 committed Nov 9, 2022
1 parent ae48f26 commit 4a4c9c3
Show file tree
Hide file tree
Showing 21 changed files with 743 additions and 510 deletions.
5 changes: 1 addition & 4 deletions active_users/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@
# Licence: Please refer to license.txt


from __future__ import unicode_literals


__version__ = "1.0.4"
__version__ = "1.0.4"
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"label": "Role",
"options": "Role",
"reqd": 1,
"in_list_view": 1
"bold": 1,
"in_list_view": 1,
"allow_in_quick_entry": 1,
"ignore_user_permissions": 1
}
],
"istable": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"label": "User",
"options": "User",
"reqd": 1,
"in_list_view": 1
"bold": 1,
"in_list_view": 1,
"allow_in_quick_entry": 1,
"ignore_user_permissions": 1
}
],
"istable": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"label": "User Type",
"options": "User Type",
"reqd": 1,
"in_list_view": 1
"bold": 1,
"in_list_view": 1,
"allow_in_quick_entry": 1,
"ignore_user_permissions": 1
}
],
"istable": 1,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"actions": [],
"allow_copy": 1,
"allow_import": 1,
"editable_grid": 1,
"autoname": "hash",
"creation": "2022-04-04 04:04:04.119400",
"description": "Active users notification receiver",
"doctype": "DocType",
"document_type": "Document",
"engine": "InnoDB",
"field_order": [
"user"
],
"fields": [
{
"fieldname": "user",
"fieldtype": "Link",
"label": "User",
"options": "User",
"reqd": 1,
"bold": 1,
"in_list_view": 1,
"allow_in_quick_entry": 1,
"ignore_user_permissions": 1
}
],
"istable": 1,
"links": [],
"modified": "2022-04-04 04:04:04.119400",
"modified_by": "Administrator",
"module": "Active Users",
"name": "Active Users Notification Receiver",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Active Users © 2022
# Author: Ameen Ahmed
# Company: Level Up Marketing & Software Development Services
# Licence: Please refer to license.txt


from frappe.model.document import Document


class ActiveUsersNotificationReceiver(Document):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,24 @@
frappe.provide('frappe._active_users');

frappe.ui.form.on('Active Users Settings', {
refresh: function(frm) {
frm.get_field('update_note').$wrapper.html(
cint(frm.doc.has_update)
? '<span class="font-weight-bold text-danger">A new version is available</span>'
: '<span class="text-muted">No new version is found</span>'
);
},
check_for_update: function(frm) {
if (frappe._active_users._init)
frappe._active_users._init.request(
'check_for_update',
function(ret) {
if (ret) frm.reload_doc();
}
);
},
after_save: function(frm) {
if (frappe._active_users._init) frappe._active_users._init.update_settings();
if (frappe._active_users._init)
frappe._active_users._init.update_settings();
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"engine": "InnoDB",
"field_order": [
"info_section",
"is_enabled",
"enabled",
"info_column",
"refresh_interval",
"allow_manual_refresh",
Expand All @@ -16,15 +16,26 @@
"hidden_from_listed_users",
"users",
"visibility_column",
"visibility_note"
"visibility_note",
"update_section",
"auto_check_for_update",
"send_update_notification",
"update_notification_sender",
"update_notification_receivers",
"update_column",
"update_note",
"has_update",
"latest_version",
"latest_check",
"check_for_update"
],
"fields": [
{
"fieldname": "info_section",
"fieldtype": "Section Break"
},
{
"fieldname": "is_enabled",
"fieldname": "enabled",
"fieldtype": "Check",
"label": "Is Enabled",
"default": "1"
Expand All @@ -38,13 +49,15 @@
"fieldtype": "Int",
"label": "Refresh Interval (Minutes)",
"description": "The number of minutes to wait before refreshing the active users list",
"default": "5"
"default": "5",
"read_only_depends_on": "eval:!doc.enabled"
},
{
"fieldname": "allow_manual_refresh",
"fieldtype": "Check",
"label": "Allow Manual Refresh",
"default": "1"
"default": "1",
"read_only_depends_on": "eval:!doc.enabled"
},
{
"fieldname": "visibility_section",
Expand All @@ -55,29 +68,34 @@
"fieldname": "user_types",
"fieldtype": "Table MultiSelect",
"label": "User Types To Display",
"options": "Active Users Has User Type"
"options": "Active Users Has User Type",
"read_only_depends_on": "eval:!doc.enabled"
},
{
"fieldname": "hidden_from_listed_roles",
"fieldtype": "Check",
"label": "Hidden From Listed Roles"
"label": "Hidden From Listed Roles",
"read_only_depends_on": "eval:!doc.enabled"
},
{
"fieldname": "roles",
"fieldtype": "Table MultiSelect",
"label": "Roles",
"options": "Active Users Has Role"
"options": "Active Users Has Role",
"read_only_depends_on": "eval:!doc.enabled"
},
{
"fieldname": "hidden_from_listed_users",
"fieldtype": "Check",
"label": "Hidden From Listed Users"
"label": "Hidden From Listed Users",
"read_only_depends_on": "eval:!doc.enabled"
},
{
"fieldname": "users",
"fieldtype": "Table MultiSelect",
"label": "Users",
"options": "Active Users Has User"
"options": "Active Users Has User",
"read_only_depends_on": "eval:!doc.enabled"
},
{
"fieldname": "visibility_column",
Expand All @@ -89,6 +107,79 @@
"label": "",
"options": "<div class=\"font-weight-bold mb-1\">Note:</div>\n<ul>\n<li>\nIf the user has any of the listed <code>Roles</code>, then the visibility of the plugin will depend on the status of the <code>Hidden From Listed Roles</code> checkbox.\n</li>\n<li class=\"mt-1\">\nIf the user exists in the listed <code>Users</code>, then the visibility of the plugin will depend on the status of the <code>Hidden From Listed Users</code> checkbox, bypassing the visibility status of listed <code>Roles</code>.\n</li>\n</ul>",
"read_only": 1
},
{
"fieldname": "update_section",
"fieldtype": "Section Break",
"label": "Update Settings"
},
{
"fieldname": "auto_check_for_update",
"fieldtype": "Check",
"label": "Auto Check",
"description": "Auto check for new version daily",
"default": "1",
"read_only_depends_on": "eval:!doc.enabled"
},
{
"fieldname": "send_update_notification",
"fieldtype": "Check",
"label": "Send Update Notification",
"default": "1",
"read_only_depends_on": "eval:!doc.enabled || !doc.auto_check_for_update"
},
{
"fieldname": "update_notification_sender",
"fieldtype": "Link",
"label": "Update Notification Sender",
"options": "User",
"read_only_depends_on": "eval:!doc.enabled || !doc.send_update_notification",
"mandatory_depends_on": "eval:doc.send_update_notification",
"ignore_user_permissions": 1
},
{
"fieldname": "update_notification_receivers",
"fieldtype": "Table MultiSelect",
"label": "Update Notification Receivers",
"options": "Active Users Notification Receiver",
"read_only_depends_on": "eval:!doc.enabled || !doc.send_update_notification",
"mandatory_depends_on": "eval:doc.send_update_notification"
},
{
"fieldname": "update_column",
"fieldtype": "Column Break"
},
{
"fieldname": "update_note",
"fieldtype": "HTML",
"label": "Update Note",
"read_only": 1
},
{
"fieldname": "has_update",
"fieldtype": "Check",
"label": "Has Update",
"hidden": 1,
"is_virtual": 1
},
{
"fieldname": "latest_version",
"fieldtype": "Data",
"label": "Latest Version",
"read_only": 1
},
{
"fieldname": "latest_check",
"fieldtype": "Data",
"label": "Latest Check",
"read_only": 1
},
{
"fieldname": "check_for_update",
"fieldtype": "Button",
"label": "Check Now",
"description": "Check for new version manually",
"read_only_depends_on": "eval:!doc.enabled"
}
],
"icon": "fa fa-cog",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
import frappe
from frappe.model.document import Document

from active_users.api.handler import _SETTINGS_CACHE_KEY
from active_users.utils import clear_document_cache, compare_versions
from active_users import __version__


class ActiveUsersSettings(Document):
@property
def has_update(self):
return 1 if compare_versions(self.latest_version, __version__) > 0 else 0


def before_save(self):
frappe.clear_cache(doctype="Active Users Settings")
frappe.cache().hdel(_SETTINGS_CACHE_KEY, frappe.session.user)
clear_document_cache(self.doctype)
Loading

0 comments on commit 4a4c9c3

Please sign in to comment.