Skip to content

Commit

Permalink
fix: cleanup Wiki Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehta committed Jun 3, 2024
1 parent 0d3aafe commit ef497df
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 157 deletions.
1 change: 1 addition & 0 deletions wiki/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
wiki.wiki.doctype.wiki_page.patches.set_allow_guest
wiki.wiki.doctype.wiki_page.patches.delete_is_new
wiki.wiki.doctype.wiki_page_revision.patches.add_usernames
wiki.wiki.doctype.wiki_feedback.patches.delete_wiki_feedback_item

[post_model_sync]
wiki.wiki.doctype.wiki_space.patches.wiki_sidebar_migration
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import frappe

def execute():
for d in frappe.db.sql("select * from `tabWiki Feedback Item`"):
frappe.get_doc(dict(
doctype = "Wiki Feedback",
status = "Open",
rating = d.rating,
feedback = d.feedback,
email_id = d.email_id
)).insert()

frappe.db.sql("update `tabWiki Feedback` set creation = %s, modified = %s" % (d.creation, d.modified))

# delete old
frappe.db.sql("delete from `tabWiki Feedback` where name = %s" % d.parent)
36 changes: 29 additions & 7 deletions wiki/wiki/doctype/wiki_feedback/wiki_feedback.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"engine": "InnoDB",
"field_order": [
"wiki_page",
"response"
"status",
"rating",
"feedback",
"email_id"
],
"fields": [
{
Expand All @@ -18,15 +21,33 @@
"reqd": 1
},
{
"fieldname": "response",
"fieldtype": "Table",
"label": "Response",
"options": "Wiki Feedback Item"
"fieldname": "rating",
"fieldtype": "Rating",
"in_list_view": 1,
"label": "Rating"
},
{
"fieldname": "feedback",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Feedback"
},
{
"fieldname": "email_id",
"fieldtype": "Data",
"label": "Email Id"
},
{
"default": "Open",
"fieldname": "status",
"fieldtype": "Select",
"label": "Status",
"options": "Open\nClosed"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-06 22:12:33.836133",
"modified": "2024-06-03 16:29:53.387846",
"modified_by": "Administrator",
"module": "Wiki",
"name": "Wiki Feedback",
Expand Down Expand Up @@ -79,5 +100,6 @@
],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
"states": [],
"title_field": "wiki_page"
}
34 changes: 11 additions & 23 deletions wiki/wiki/doctype/wiki_feedback/wiki_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,14 @@ class WikiFeedback(Document):
@frappe.whitelist(allow_guest=True)
def submit_feedback(name, feedback, rating, email=None, feedback_index=None):
email = validate_email_address(email)

if feedback_name := frappe.db.get_value("Wiki Feedback", {"wiki_page": name}):
doc = frappe.get_doc("Wiki Feedback", feedback_name)
if feedback_index:
feedback_index = int(feedback_index)

doc.response[feedback_index - 1].rating = rating
doc.response[feedback_index - 1].feedback = feedback
doc.response[feedback_index - 1].email_id = email
else:
doc.append("response", {"rating": rating, "feedback": feedback, "email_id": email})
doc.save()
return feedback_index if feedback_index else len(doc.response)
else:
doc = frappe.get_doc(
{
"doctype": "Wiki Feedback",
"wiki_page": name,
}
)
doc.append("response", {"rating": rating, "feedback": feedback, "email_id": email})
doc.insert()
return 1
doc = frappe.get_doc(
{
"doctype": "Wiki Feedback",
"wiki_page": name,
"rating": rating,
"feedback": feedback,
"email_id": email
}
)
doc.insert()
return 1
Empty file.
44 changes: 0 additions & 44 deletions wiki/wiki/doctype/wiki_feedback_item/wiki_feedback_item.json

This file was deleted.

9 changes: 0 additions & 9 deletions wiki/wiki/doctype/wiki_feedback_item/wiki_feedback_item.py

This file was deleted.

20 changes: 13 additions & 7 deletions wiki/wiki/doctype/wiki_settings/wiki_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
"table_of_contents_section",
"collapse_sidebar_groups",
"enable_table_of_contents",
"feedback_section",
"enable_feedback",
"ask_for_contact_details",
"section_break_mmtu",
"javascript",
"navbar_tab",
"navbar_column",
"navbar",
"section_break_skhp",
"search_column",
"add_search_bar",
"use_redisearch_for_search"
"use_redisearch_for_search",
"feedback_tab",
"feedback_section",
"enable_feedback",
"ask_for_contact_details",
"section_break_mmtu",
"javascript"
],
"fields": [
{
Expand Down Expand Up @@ -150,12 +151,17 @@
"fieldname": "ask_for_contact_details",
"fieldtype": "Check",
"label": "Ask for contact details"
},
{
"fieldname": "feedback_tab",
"fieldtype": "Tab Break",
"label": "Feedback"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2023-12-06 16:37:55.392279",
"modified": "2024-06-03 16:19:02.137666",
"modified_by": "Administrator",
"module": "Wiki",
"name": "Wiki Settings",
Expand Down
142 changes: 75 additions & 67 deletions wiki/wiki/workspace/wiki/wiki.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,76 @@
{
"charts": [],
"content": "[{\"id\":\"f6laZQUa0x\",\"type\":\"header\",\"data\":{\"text\":\"<span class=\\\"h4\\\">Wiki</span>\",\"col\":12}},{\"id\":\"ir8Llemis5\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Wiki Pages\",\"col\":4}},{\"id\":\"tZQ_AtqABm\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Wiki Space\",\"col\":3}},{\"id\":\"z4qT3yMggL\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Wiki Settings\",\"col\":4}},{\"id\":\"cTIBC0weUT\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Wiki Page Patches\",\"col\":4}},{\"id\":\"BsC6YwujPn\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Wiki Page Revisions\",\"col\":4}}]",
"creation": "2022-09-25 16:45:20.547072",
"custom_blocks": [],
"docstatus": 0,
"doctype": "Workspace",
"for_user": "",
"hide_custom": 0,
"icon": "education",
"idx": 0,
"is_hidden": 0,
"label": "Wiki",
"links": [],
"modified": "2023-07-23 13:03:07.200464",
"modified_by": "Administrator",
"module": "Wiki",
"name": "Wiki",
"number_cards": [],
"owner": "Administrator",
"parent_page": "",
"public": 1,
"quick_lists": [],
"roles": [],
"sequence_id": 31.0,
"shortcuts": [
{
"color": "Blue",
"doc_view": "List",
"format": "{} Published",
"label": "Wiki Pages",
"link_to": "Wiki Page",
"stats_filter": "{\"published\":[\"=\",1]}",
"type": "DocType"
},
{
"color": "Grey",
"doc_view": "List",
"label": "Wiki Space",
"link_to": "Wiki Space",
"type": "DocType"
},
{
"color": "Yellow",
"doc_view": "List",
"format": "{} Under Review",
"label": "Wiki Page Patches",
"link_to": "Wiki Page Patch",
"stats_filter": "{\"status\":[\"=\",\"Under Review\"]}",
"type": "DocType"
},
{
"color": "Grey",
"doc_view": "List",
"label": "Wiki Settings",
"link_to": "Wiki Settings",
"type": "DocType"
},
{
"color": "Grey",
"doc_view": "List",
"label": "Wiki Page Revisions",
"link_to": "Wiki Page Revision",
"type": "DocType"
}
],
"title": "Wiki"
}
"charts": [],
"content": "[{\"id\":\"f6laZQUa0x\",\"type\":\"header\",\"data\":{\"text\":\"<span class=\\\"h4\\\">Wiki</span>\",\"col\":12}},{\"id\":\"ir8Llemis5\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Wiki Pages\",\"col\":4}},{\"id\":\"tZQ_AtqABm\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Wiki Space\",\"col\":4}},{\"id\":\"z4qT3yMggL\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Wiki Settings\",\"col\":4}},{\"id\":\"cTIBC0weUT\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Wiki Page Patches\",\"col\":4}},{\"id\":\"IfrRKY62Tc\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Wiki Feedback\",\"col\":4}},{\"id\":\"BsC6YwujPn\",\"type\":\"shortcut\",\"data\":{\"shortcut_name\":\"Wiki Page Revisions\",\"col\":4}}]",
"creation": "2022-09-25 16:45:20.547072",
"custom_blocks": [],
"docstatus": 0,
"doctype": "Workspace",
"for_user": "",
"hide_custom": 0,
"icon": "education",
"idx": 0,
"is_hidden": 0,
"label": "Wiki",
"links": [],
"modified": "2024-06-03 16:10:59.630080",
"modified_by": "Administrator",
"module": "Wiki",
"name": "Wiki",
"number_cards": [],
"owner": "Administrator",
"parent_page": "",
"public": 1,
"quick_lists": [],
"roles": [],
"sequence_id": 31.0,
"shortcuts": [
{
"color": "Blue",
"doc_view": "List",
"format": "{} Published",
"label": "Wiki Pages",
"link_to": "Wiki Page",
"stats_filter": "{\"published\":[\"=\",1]}",
"type": "DocType"
},
{
"color": "Grey",
"doc_view": "List",
"label": "Wiki Feedback",
"link_to": "Wiki Feedback",
"stats_filter": "[]",
"type": "DocType"
},
{
"color": "Grey",
"doc_view": "List",
"label": "Wiki Space",
"link_to": "Wiki Space",
"type": "DocType"
},
{
"color": "Yellow",
"doc_view": "List",
"format": "{} Under Review",
"label": "Wiki Page Patches",
"link_to": "Wiki Page Patch",
"stats_filter": "{\"status\":[\"=\",\"Under Review\"]}",
"type": "DocType"
},
{
"color": "Grey",
"doc_view": "List",
"label": "Wiki Settings",
"link_to": "Wiki Settings",
"type": "DocType"
},
{
"color": "Grey",
"doc_view": "List",
"label": "Wiki Page Revisions",
"link_to": "Wiki Page Revision",
"type": "DocType"
}
],
"title": "Wiki"
}

0 comments on commit ef497df

Please sign in to comment.