mirror of
https://github.com/erpnext/foundation.git
synced 2026-10-16 18:00:47 +02:00
[new] Service Provier Deactivation Alert
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.website.website_generator import WebsiteGenerator
|
||||
from frappe.utils import get_datetime
|
||||
|
||||
class ServiceProvider(WebsiteGenerator):
|
||||
_website = frappe._dict(
|
||||
@@ -21,4 +22,27 @@ class ServiceProvider(WebsiteGenerator):
|
||||
if self.member:
|
||||
context.membership_type = frappe.get_value('Member', self.member, 'membership_type')
|
||||
if context.website and not context.website.startswith('http'):
|
||||
context.website = 'http://' + context.website
|
||||
context.website = 'http://' + context.website
|
||||
|
||||
|
||||
def send_alert_to_inactive_service_providers():
|
||||
for service_provider in frappe.get_all("Service Provider", fields=['email', 'title']):
|
||||
if get_last_login_diff(service_provider.email) == 80:
|
||||
send_reminder(service_provider)
|
||||
|
||||
def send_reminder(service_provider_details):
|
||||
message = frappe.render_template("foundation/templates/emails/inactivity_reminder.md", service_provider_details)
|
||||
frappe.sendmail(recipients=service_provider_details.email, subject="About account inactivity", message=message)
|
||||
|
||||
def unpublish_service_provider():
|
||||
for service_provider in frappe.get_all("Service Provider", fields=['name', 'title']):
|
||||
if get_last_login_diff(service_provider.email) == 90:
|
||||
frappe.db.set_value('Service Provider', service_provider.name, 'show_in_website', 0, update_modified=False)
|
||||
|
||||
|
||||
def get_last_login_diff(user):
|
||||
"""
|
||||
Returns difference between todays date and last login date
|
||||
"""
|
||||
last_login = frappe.db.get_value("User", user, ["last_login"])
|
||||
return (get_datetime() - get_datetime(last_login)).days
|
||||
@@ -116,23 +116,24 @@ portal_menu_items = [
|
||||
# Scheduled Tasks
|
||||
# ---------------
|
||||
|
||||
# scheduler_events = {
|
||||
# "all": [
|
||||
# "foundation.tasks.all"
|
||||
# ],
|
||||
# "daily": [
|
||||
# "foundation.tasks.daily"
|
||||
# ],
|
||||
# "hourly": [
|
||||
# "foundation.tasks.hourly"
|
||||
# ],
|
||||
# "weekly": [
|
||||
# "foundation.tasks.weekly"
|
||||
# ]
|
||||
# "monthly": [
|
||||
# "foundation.tasks.monthly"
|
||||
# ]
|
||||
# }
|
||||
scheduler_events = {
|
||||
# "all": [
|
||||
# "foundation.tasks.all"
|
||||
# ],
|
||||
"daily": [
|
||||
"erpnext_foundation.doctype.service_provider.service_provider.send_alert_to_inactive_service_providers",
|
||||
"erpnext_foundation.doctype.service_provider.service_provider.unpublish_service_provider",
|
||||
],
|
||||
# "hourly": [
|
||||
# "foundation.tasks.hourly"
|
||||
# ],
|
||||
# "weekly": [
|
||||
# "foundation.tasks.weekly"
|
||||
# ]
|
||||
# "monthly": [
|
||||
# "foundation.tasks.monthly"
|
||||
# ]
|
||||
}
|
||||
|
||||
# Testing
|
||||
# -------
|
||||
|
||||
8
foundation/templates/emails/inactivity_reminder.md
Normal file
8
foundation/templates/emails/inactivity_reminder.md
Normal file
@@ -0,0 +1,8 @@
|
||||
Hi {{ title }},
|
||||
|
||||
This is a Service Provider listing deactivation alert,
|
||||
You have not login since last 80 days, if you are not login in next 10 days
|
||||
erpnext.org might removed your name from a service provider listing.
|
||||
|
||||
Thanks,
|
||||
ERPNext Foundation
|
||||
Reference in New Issue
Block a user