Merge pull request #2762 from mbauskar/feedback

[minor] feedback ratings document type filters
This commit is contained in:
Nabin Hait 2017-02-27 12:25:52 +05:30 committed by GitHub
commit 6f9db9eb70
4 changed files with 47 additions and 23 deletions

View file

@ -88,7 +88,8 @@ def get_feedback_request_details(reference_doctype, reference_name, trigger=None
communications = frappe.get_all("Communication", filters={
"reference_doctype": reference_doctype,
"reference_name": reference_name,
"communication_type": "Communication"
"communication_type": "Communication",
"sent_or_received": "Sent"
}, fields=["name"])
if len(communications) < 1:

View file

@ -4,23 +4,28 @@
frappe.query_reports["Feedback Ratings"] = {
"filters": [
{
"fieldname": "party_type",
"label": __("Party Type"),
"fieldname": "document_type",
"label": __("Document Type"),
"fieldtype": "Link",
"options": "DocType",
"reqd": 1,
"default": "Issue"
"default": "Issue",
"get_query": function() {
return {
"query": "frappe.core.report.feedback_ratings.feedback_ratings.get_document_type"
}
}
},
{
"fieldname": "party_name",
"label": __("Party"),
"fieldname": "document_id",
"label": __("Document ID"),
"fieldtype": "Dynamic Link",
"get_options": function() {
var party_type = frappe.query_report_filters_by_name.party_type.get_value();
if(!party_type) {
frappe.throw(__("Please select Party Type first"));
var document_type = frappe.query_report_filters_by_name.document_type.get_value();
if(!document_type) {
frappe.throw(__("Please select Document Type first"));
}
return party_type;
return document_type;
}
},
{

View file

@ -16,16 +16,16 @@ def get_columns(filters):
def get_data(filters):
data = []
party_type = filters.get("party_type")
party = filters.get("party_name")
document_type = filters.get("document_type")
party = filters.get("document_id")
filters = {
"reference_doctype": party_type,
"reference_doctype": document_type,
"communication_type": "Feedback",
"creation": ["Between", [filters.get("from_date"), filters.get("to_date")]]
}
fields = ["DATE_FORMAT(DATE(creation),'%m-%d-%Y')", "avg(rating) as rating"]
if not party_type:
if not document_type:
return []
if party:
@ -35,3 +35,24 @@ def get_data(filters):
order_by="creation", group_by="DATE_FORMAT(DATE(creation),'%m-%d-%Y')", as_list=True)
return party_details or []
@frappe.whitelist()
def get_document_type(doctype, txt, searchfield, start, page_len, filters):
""" get the document type """
document_type = []
txt = "%%%s%%" % txt
document_type = frappe.get_all("Feedback Trigger", filters={ "enabled": 1, "document_type": ("like", txt) },
fields=["document_type"], as_list=True)
document_type = map(list, document_type)
to_ignore = [ doc[0] for doc in document_type ]
documents = frappe.get_all("Feedback Request", filters={ "reference_doctype": ["not in", to_ignore] },
fields=["reference_doctype"], distinct=True, as_list=True)
if documents:
document_type.extend(documents)
return document_type

View file

@ -1,11 +1,8 @@
<div align="center">
<p>{{ _("Please select a rating") }}</p>
<div class="user-ratings">
<a class="rating" style="text-decoration: none; color: grey" href="{{url}}&rating=1"></a>
<a class="rating" style="text-decoration: none; color: grey" href="{{url}}&rating=2"></a>
<a class="rating" style="text-decoration: none; color: grey" href="{{url}}&rating=3"></a>
<a class="rating" style="text-decoration: none; color: grey" href="{{url}}&rating=4"></a>
<a class="rating" style="text-decoration: none; color: grey" href="{{url}}&rating=5"></a>
</div>
</div>
<a style="display: inline-block;width: 32px;height: 30px;border-top-left-radius: 6px;border-top-right-radius: 6px;border-bottom-right-radius: 6px;border-bottom-left-radius: 6px;background-color: rgb(255,255,255);border-color: rgb(204,204,204);border-style: solid;border-width: 1px 1px 3px;line-height: 30px;text-decoration: none;font-size: 18px;font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;font-weight: bold;" href="{{url}}&rating=1">1</a>
<a style="display: inline-block;width: 32px;height: 30px;border-top-left-radius: 6px;border-top-right-radius: 6px;border-bottom-right-radius: 6px;border-bottom-left-radius: 6px;background-color: rgb(255,255,255);border-color: rgb(204,204,204);border-style: solid;border-width: 1px 1px 3px;line-height: 30px;text-decoration: none;font-size: 18px;font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;font-weight: bold;" href="{{url}}&rating=2">2</a>
<a style="display: inline-block;width: 32px;height: 30px;border-top-left-radius: 6px;border-top-right-radius: 6px;border-bottom-right-radius: 6px;border-bottom-left-radius: 6px;background-color: rgb(255,255,255);border-color: rgb(204,204,204);border-style: solid;border-width: 1px 1px 3px;line-height: 30px;text-decoration: none;font-size: 18px;font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;font-weight: bold;" href="{{url}}&rating=3">3</a>
<a style="display: inline-block;width: 32px;height: 30px;border-top-left-radius: 6px;border-top-right-radius: 6px;border-bottom-right-radius: 6px;border-bottom-left-radius: 6px;background-color: rgb(255,255,255);border-color: rgb(204,204,204);border-style: solid;border-width: 1px 1px 3px;line-height: 30px;text-decoration: none;font-size: 18px;font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;font-weight: bold;" href="{{url}}&rating=4">4</a>
<a style="display: inline-block;width: 32px;height: 30px;border-top-left-radius: 6px;border-top-right-radius: 6px;border-bottom-right-radius: 6px;border-bottom-left-radius: 6px;background-color: rgb(255,255,255);border-color: rgb(204,204,204);border-style: solid;border-width: 1px 1px 3px;line-height: 30px;text-decoration: none;font-size: 18px;font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif;font-weight: bold;" href="{{url}}&rating=5">5</a>
</div>