Skip to content

Commit

Permalink
Merge pull request #35 from ONE-F-M/staging
Browse files Browse the repository at this point in the history
Staging to master-14
  • Loading branch information
mymi14s authored Aug 29, 2023
2 parents ec6259b + f8bf761 commit 458839e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 36 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
cd /home/frappe/frappe-bench
bench restart ${{secrets.PASSKEY}}
# bench setup requirements
bench build
bench build --app one_wiki
bench clear-cache
bench clear-website-cache
bench migrate # sync database
# we remove any unused dependencies
bench doctor
Expand Down
1 change: 1 addition & 0 deletions one_wiki/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
# Authentication and authorization
# --------------------------------


# auth_hooks = [
# "one_wiki.auth.validate"
# ]
48 changes: 23 additions & 25 deletions one_wiki/overrides/wiki_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def update(

if frappe.has_permission(doctype="Wiki Page Patch", ptype="submit", throw=False) and not draft:
patch.approved_by = frappe.session.user
patch.status = "Approved" if rejected=='false' else "Rejected"
patch.status = "Approved" if rejected in ['false',False] else "Rejected"
patch.submit()
out.approved = True

Expand All @@ -95,30 +95,28 @@ def get_sidebar_items_(self):

for sidebar_item in wiki_sidebar:
wiki_page = frappe.get_doc("Wiki Page", sidebar_item.wiki_page)
wiki_language = frappe.cache().get_value(f'wiki_language_{frappe.session.user}')
if wiki_language in ['en','ar']:
wiki_language_dict = {'en':'English','ar':'عربي'}
if wiki_page.language == wiki_language_dict[wiki_language]:
if sidebar_item.parent_label not in sidebar:
sidebar[sidebar_item.parent_label] = [
{
"name": wiki_page.name,
"type": "Wiki Page",
"title": wiki_page.title,
"route": wiki_page.route,
"group_name": sidebar_item.parent_label,
}
]
else:
sidebar[sidebar_item.parent_label] += [
{
"name": wiki_page.name,
"type": "Wiki Page",
"title": wiki_page.title,
"route": wiki_page.route,
"group_name": sidebar_item.parent_label,
}
]
wiki_language = self.language or 'English'
if wiki_page.language == wiki_language:
if sidebar_item.parent_label not in sidebar:
sidebar[sidebar_item.parent_label] = [
{
"name": wiki_page.name,
"type": "Wiki Page",
"title": wiki_page.title,
"route": wiki_page.route,
"group_name": sidebar_item.parent_label,
}
]
else:
sidebar[sidebar_item.parent_label] += [
{
"name": wiki_page.name,
"type": "Wiki Page",
"title": wiki_page.title,
"route": wiki_page.route,
"group_name": sidebar_item.parent_label,
}
]

return self.get_items(sidebar)

Expand Down
6 changes: 5 additions & 1 deletion one_wiki/public/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const getContent = () => {
};

const saveWikiPage = (draft = false) => {
console.log("INSIDE FUNC")
const urlParams = new URLSearchParams(window.location.search);
const isEmptyEditor = !!urlParams.get("newWiki");

Expand Down Expand Up @@ -385,11 +386,14 @@ buttons.deleteTable.addEventListener("click", () => {
});

buttons.saveWikiPage.addEventListener("click", () => {

if(window.is_wiki_manager){
console.log("CALLED HERE11111")
saveWikiPage(draft = true);
}
else{
console.log("CALLED HERE222222")
console.log(window.is_wiki_manager)
saveWikiPage();
}

Expand Down
23 changes: 14 additions & 9 deletions one_wiki/templates/wiki_page/templates/wiki_doc.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,7 @@ <h5>On this page</h5>
$("#ar_lang").click(()=>{
change_lang($("#ar_lang").html())
})
if('{{lang}}'=='en'){
;

}
else{

;
}


function is_editable_page(){
let value = window.location.search ? true : false
Expand All @@ -115,7 +108,16 @@ <h5>On this page</h5>
$('.btn.btn-primary.save-wiki-page-btn.btn-sm').attr('data-tiptap-button', 'draftWikiPage')
$('.btn.btn-primary.btn-sm.dropdown-toggle.dropdown-toggle-split').hide()
}

if(('{{is_wiki_manager}}'=='1')&& '{{can_approve}}' != "True"){
$('.btn.btn-primary.save-wiki-page-btn.btn-sm').html("Submit")
$('.btn.btn-primary.save-wiki-page-btn.btn-sm').attr('data-tiptap-button', 'draftWikiPage');
$('.btn.btn-primary.save-wiki-page-btn.btn-sm').off('click', 'saveWikiPage');
$('[data-tiptap-button="saveWikiPage"]').hide()
$('.btn.btn-primary.save-wiki-page-btn.btn-sm').click(()=>{
saveWikiPage(draft=false)
})

}
if('{{can_approve}}' == "True"){

$('.btn.btn-primary.save-wiki-page-btn.btn-sm').hide()
Expand Down Expand Up @@ -175,6 +177,9 @@ <h5>On this page</h5>

}
const saveWikiPage = (draft = false,rejected = false) => {
console.log("CLICKED OOO")
console.log(draft)
console.log(rejected)
const urlParams = new URLSearchParams(window.location.search);
const isEmptyEditor = !!urlParams.get("newWiki");

Expand Down

0 comments on commit 458839e

Please sign in to comment.