Przeglądaj źródła

Migrate bookmarks to stars #1000, sync boot docs loaded with desk.html

version-14
Anand Doshi 10 lat temu
rodzic
commit
a03db0c223
5 zmienionych plików z 45 dodań i 6 usunięć
  1. +15
    -5
      frappe/desk/star.py
  2. +1
    -0
      frappe/patches.txt
  3. +25
    -0
      frappe/patches/v5_0/bookmarks_to_stars.py
  4. +1
    -0
      frappe/public/js/frappe/desk.js
  5. +3
    -1
      frappe/templates/pages/desk.html

+ 15
- 5
frappe/desk/star.py Wyświetl plik

@@ -19,6 +19,15 @@ def toggle_star(doctype, name, add=False):
:param doctype: DocType of the document to star
:param name: Name of the document to star
:param add: `Yes` if star is to be added. If not `Yes` the star will be removed."""

_toggle_star(doctype, name, add)

def _toggle_star(doctype, name, add=False, user=None):
"""Same as toggle_star but hides param `user` from API"""

if not user:
user = frappe.session.user

try:
starred_by = frappe.db.get_value(doctype, name, "_starred_by")
if starred_by:
@@ -27,17 +36,18 @@ def toggle_star(doctype, name, add=False):
starred_by = []

if add=="Yes":
if frappe.session.user not in starred_by:
starred_by.append(frappe.session.user)
if user not in starred_by:
starred_by.append(user)
else:
if frappe.session.user in starred_by:
starred_by.remove(frappe.session.user)
if user in starred_by:
starred_by.remove(user)

frappe.db.sql("""update `tab{0}` set `_starred_by`=%s where name=%s""".format(doctype),
(json.dumps(starred_by), name))

except Exception, e:
if e.args[0]==1054:
add_column(doctype, "_starred_by", "Text")
toggle_star(doctype, name, add)
_toggle_star(doctype, name, add, user)
else:
raise

+ 1
- 0
frappe/patches.txt Wyświetl plik

@@ -63,3 +63,4 @@ frappe.patches.v5_0.clear_website_group_and_notifications
execute:frappe.db.sql("""update tabComment set comment = substr(comment, 6, locate(":", comment)-6) where comment_type in ("Assigned", "Assignment Completed")""")
frappe.patches.v5_0.fix_feed
frappe.patches.v5_0.update_shared
frappe.patches.v5_0.bookmarks_to_stars

+ 25
- 0
frappe/patches/v5_0/bookmarks_to_stars.py Wyświetl plik

@@ -0,0 +1,25 @@
from __future__ import unicode_literals
import json
import frappe
import frappe.defaults
from frappe.desk.star import _toggle_star

def execute():
for user in frappe.get_all("User"):
username = user["name"]
bookmarks = frappe.db.get_default("_bookmarks", username)

if not bookmarks:
continue

if isinstance(bookmarks, basestring):
bookmarks = json.loads(bookmarks)

for opts in bookmarks:
route = (opts.get("route") or "").strip("#/ ")

if route and route.startswith("Form"):
view, doctype, docname = opts["route"].split("/")

if frappe.db.exists(doctype, docname):
_toggle_star(doctype, docname, add="Yes", user=username)

+ 1
- 0
frappe/public/js/frappe/desk.js Wyświetl plik

@@ -51,6 +51,7 @@ frappe.Application = Class.extend({
load_bootinfo: function() {
if(frappe.boot) {
frappe.modules = frappe.boot.modules;
frappe.model.sync(frappe.boot.docs);
this.check_metadata_cache_status();
this.set_globals();
this.sync_pages();


+ 3
- 1
frappe/templates/pages/desk.html Wyświetl plik

@@ -1,13 +1,15 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Frappe Desk</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0,
maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="white">
<meta name="mobile-web-app-capable" content="yes">
<title>Frappe Desk</title>
<link rel="shortcut icon"
href="{{ favicon or "/assets/frappe/images/favicon.ico" }}" type="image/x-icon">
<link rel="icon"


Ładowanie…
Anuluj
Zapisz