浏览代码

Fixed merge conflict

version-14
Nabin Hait 8 年前
父节点
当前提交
4cf123bd8f
共有 10 个文件被更改,包括 67 次插入43 次删除
  1. +3
    -3
      frappe/__init__.py
  2. +0
    -10
      frappe/commands/scheduler.py
  3. +22
    -0
      frappe/commands/site.py
  4. +5
    -0
      frappe/config/desk.py
  5. +0
    -5
      frappe/config/setup.py
  6. +7
    -3
      frappe/core/doctype/communication/communication.py
  7. +1
    -1
      frappe/email/doctype/auto_email_report/auto_email_report.js
  8. +13
    -4
      frappe/utils/pdf.py
  9. +15
    -17
      frappe/utils/print_format.py
  10. +1
    -0
      requirements.txt

+ 3
- 3
frappe/__init__.py 查看文件

@@ -13,7 +13,7 @@ import os, sys, importlib, inspect, json
from .exceptions import *
from .utils.jinja import get_jenv, get_template, render_template

__version__ = '7.1.19'
__version__ = '7.1.20'
__title__ = "Frappe Framework"

local = Local()
@@ -1149,7 +1149,7 @@ def format(*args, **kwargs):
import frappe.utils.formatters
return frappe.utils.formatters.format_value(*args, **kwargs)

def get_print(doctype=None, name=None, print_format=None, style=None, html=None, as_pdf=False, doc=None):
def get_print(doctype=None, name=None, print_format=None, style=None, html=None, as_pdf=False, doc=None, output = None):
"""Get Print Format for given document.

:param doctype: DocType of document.
@@ -1170,7 +1170,7 @@ def get_print(doctype=None, name=None, print_format=None, style=None, html=None,
html = build_page("print")

if as_pdf:
return get_pdf(html)
return get_pdf(html, output = output)
else:
return html



+ 0
- 10
frappe/commands/scheduler.py 查看文件

@@ -145,15 +145,6 @@ def purge_jobs(site=None, queue=None, event=None):
count = purge_pending_jobs(event=event, site=site, queue=queue)
print "Purged {} jobs".format(count)

@click.command('dump-queue-status')
def dump_queue_status():
"Dump detailed diagnostic infomation for task queues in JSON format"
frappe.init('')
from frappe.utils.doctor import dump_queue_status as _dump_queue_status, inspect_queue
print json.dumps(_dump_queue_status(), indent=1)
inspect_queue()


@click.command('schedule')
def start_scheduler():
from frappe.utils.scheduler import start_scheduler
@@ -192,7 +183,6 @@ def ready_for_migration(context, site=None):
commands = [
disable_scheduler,
doctor,
dump_queue_status,
enable_scheduler,
purge_jobs,
ready_for_migration,


+ 22
- 0
frappe/commands/site.py 查看文件

@@ -483,6 +483,27 @@ def set_last_active_for_user(context, user=None):
set_last_active_to_now(user)
frappe.db.commit()

@click.command('publish-realtime')
@click.argument('event')
@click.option('--message')
@click.option('--room')
@click.option('--user')
@click.option('--doctype')
@click.option('--docname')
@click.option('--after-commit')
@pass_context
def publish_realtime(context, event, message, room, user, doctype, docname, after_commit):
"Publish realtime event from bench"
from frappe import publish_realtime
for site in context.sites:
try:
frappe.init(site=site)
frappe.connect()
publish_realtime(event, message=message, room=room, user=user, doctype=doctype, docname=docname,
after_commit=after_commit)
frappe.db.commit()
finally:
frappe.destroy()

commands = [
add_system_manager,
@@ -506,4 +527,5 @@ commands = [
disable_user,
_use,
set_last_active_for_user,
publish_realtime,
]

+ 5
- 0
frappe/config/desk.py 查看文件

@@ -7,6 +7,11 @@ def get_data():
"label": _("Tools"),
"icon": "octicon octicon-briefcase",
"items": [
{
"type": "doctype",
"name": "Newsletter",
"description": _("Newsletters to contacts, leads."),
},
{
"type": "doctype",
"name": "ToDo",


+ 0
- 5
frappe/config/setup.py 查看文件

@@ -144,11 +144,6 @@ def get_data():
"name": "Standard Reply",
"description": _("Standard replies to common queries.")
},
{
"type": "doctype",
"name": "Newsletter",
"description": _("Newsletters to contacts, leads."),
},
{
"type": "doctype",
"name": "Email Group",


+ 7
- 3
frappe/core/doctype/communication/communication.py 查看文件

@@ -231,6 +231,10 @@ def on_doctype_update():
frappe.db.add_index("Communication", ["modified"])

def has_permission(doc, ptype, user):
if ptype=="read" and doc.reference_doctype and doc.reference_name:
if frappe.has_permission(doc.reference_doctype, ptype="read", doc=doc.reference_name):
return True
if ptype=="read":
if doc.reference_doctype and doc.reference_name:
if frappe.has_permission(doc.reference_doctype, ptype="read", doc=doc.reference_name):
return True
if doc.timeline_doctype and doc.timeline_name:
if frappe.has_permission(doc.timeline_doctype, ptype="read", doc=doc.timeline_name):
return True

+ 1
- 1
frappe/email/doctype/auto_email_report/auto_email_report.js 查看文件

@@ -4,7 +4,7 @@
frappe.ui.form.on('Auto Email Report', {
refresh: function(frm) {
if(frm.doc.report_type !== 'Report Builder') {
if(frm.script_setup_for !== frm.doc.report) {
if(frm.script_setup_for !== frm.doc.report && !frm.doc.__islocal) {
frappe.call({
method:"frappe.desk.query_report.get_script",
args: {


+ 13
- 4
frappe/utils/pdf.py 查看文件

@@ -6,17 +6,20 @@ import pdfkit, os, frappe
from frappe.utils import scrub_urls
from frappe import _
from bs4 import BeautifulSoup
from pyPdf import PdfFileWriter, PdfFileReader

def get_pdf(html, options=None):
def get_pdf(html, options=None, output = None):
html = scrub_urls(html)
html, options = prepare_options(html, options)
fname = os.path.join("/tmp", "frappe-pdf-{0}.pdf".format(frappe.generate_hash()))

try:
pdfkit.from_string(html, fname, options=options or {})

with open(fname, "rb") as fileobj:
filedata = fileobj.read()
if output:
append_pdf(PdfFileReader(file(fname,"rb")),output)
else:
with open(fname, "rb") as fileobj:
filedata = fileobj.read()

except IOError, e:
if ("ContentNotFoundError" in e.message
@@ -37,9 +40,15 @@ def get_pdf(html, options=None):
finally:
cleanup(fname, options)

if output:
return output

return filedata

def append_pdf(input,output):
# Merging multiple pdf files
[output.addPage(input.getPage(page_num)) for page_num in range(input.numPages)]

def prepare_options(html, options):
if not options:
options = {}


+ 15
- 17
frappe/utils/print_format.py 查看文件

@@ -7,6 +7,7 @@ from frappe.modules import get_doc_path
from jinja2 import TemplateNotFound
from frappe.utils import cint, strip_html
from frappe.utils.pdf import get_pdf
from pyPdf import PdfFileWriter, PdfFileReader

no_cache = 1
no_sitemap = 1
@@ -17,31 +18,28 @@ standard_format = "templates/print_formats/standard.html"
@frappe.whitelist()
def download_multi_pdf(doctype, name, format=None):
# name can include names of many docs of the same doctype.
totalhtml = ""
# Pagebreak to be added between each doc html
pagebreak = """<p style="page-break-after:always;"></p>"""

options = {}

import json
result = json.loads(name)
# Get html of each doc and combine including page breaks

# Concatenating pdf files
output = PdfFileWriter()
for i, ss in enumerate(result):
html = frappe.get_print(doctype, ss, format)
if i == len(result)-1:
totalhtml = totalhtml + html
else:
totalhtml = totalhtml + html + pagebreak
output = frappe.get_print(doctype, ss, format, as_pdf = True, output = output)

frappe.local.response.filename = "{doctype}.pdf".format(doctype=doctype.replace(" ", "-").replace("/", "-"))
frappe.local.response.filecontent = read_multi_pdf(output)
frappe.local.response.type = "download"

# Title of pdf
options.update({
'title': doctype,
})
def read_multi_pdf(output):
# Get the content of the merged pdf files
fname = os.path.join("/tmp", "frappe-pdf-{0}.pdf".format(frappe.generate_hash()))
output.write(open(fname,"wb"))

frappe.local.response.filecontent = get_pdf(totalhtml, options)
frappe.local.response.type = "download"
with open(fname, "rb") as fileobj:
filedata = fileobj.read()

return filedata

@frappe.whitelist()
def download_pdf(doctype, name, format=None, doc=None):


+ 1
- 0
requirements.txt 查看文件

@@ -40,3 +40,4 @@ unittest-xml-reporting
xlwt
oauthlib
PyJWT
pypdf

正在加载...
取消
保存