Dave Kimmel
2017-10-01 15:31:07 UTC
Hey there,
A common request seems to be âHow do I remove the Workflow/Cabinets/Tags menus from Mayan?â. Hopefully this post can answer that question once and for all.
There are two things that need to be done to do this: Create a custom app which does the removal, make Mayan load the custom app as part of its startup processing.
1) Create a custom app:
First, go to the Mayan apps directory (/usr/local/mayan-edms/mayan/apps on my install) and create a directory for the custom app. I called mine âzzzcustomâ, this is a name that probably wonât conflict with anything delivered in the future.
Next, create the following files in that new directory (âŠâŠ/mayan/apps/zzzcustom) with the following contents:
__init__.py:
from __future__ import unicode_literals
default_app_config = 'zzzcustom.apps.ZZZCustomApp'
apps.py:
from __future__ import unicode_literals
from django.utils.translation import ugettext_lazy as _
from common import MayanAppConfig
from common import menu_main
from tags.menus import menu_tags
from cabinets.menus import menu_cabinets
from document_states.links import link_workflow_list
from checkouts.links import link_checkout_list
class ZZZCustomApp(MayanAppConfig):
name = 'zzzcustom'
verbose_name = _('Custom Stuff')
def ready(self):
super(ZZZCustomApp, self).ready()
# Remove "Tags" links from main menu
menu_main.unbind_links(links=(menu_tags,),)
# Remove "Cabients" from main menu
menu_main.unbind_links(links=(menu_cabinets,),)
# Remove "Workflow" from main menu
menu_main.unbind_links(links=(link_workflow_list,),)
# Remove "Checkouts" from main menu
menu_main.unbind_links(links=(link_checkout_list,),)
You can comment out or remove calls to menu_main.unbind_links if you want to keep those options available.
2) Add the following to your settings/local.py:
INSTALLED_APPS += ('zzzcustom',)
At this point you should be able to start Mayan and no longer see the Tags, Cabinets, Workflow, and Checkouts menus.
So how does all this work?
The line in local.py adds the custom app into the list of installed apps. Mayan uses this to figure out what objects to load, so this makes it load the custom app.
The line in __init__.py is required by Django (which Mayan uses as its framework) to tell it what class to use to initialize the app.
Finally, apps.py has the code that actually initializes the custom app. The ready method within the configuration class (ZZZCustomApp) tells Mayanâs menu_main object to unbind various links. The link objects that are being unbound are imported from the various apps that provide them. Removing other items requires looking through the source of the app that provides them, figuring out how they are bound to the main menu, then writing code in the custom app to unbind them.
Why use a custom app for this? Simple - if you modify the delivered Mayan code, you have to remodify it every time you upgrade. By using a custom app it should survive upgrades and require no (or minimal) changes.
Hopefully this is enough to get everyone who wants to remove items from the main menu started.
Thanks,
-- Dave Kimmel
***@gmail.com
A common request seems to be âHow do I remove the Workflow/Cabinets/Tags menus from Mayan?â. Hopefully this post can answer that question once and for all.
There are two things that need to be done to do this: Create a custom app which does the removal, make Mayan load the custom app as part of its startup processing.
1) Create a custom app:
First, go to the Mayan apps directory (/usr/local/mayan-edms/mayan/apps on my install) and create a directory for the custom app. I called mine âzzzcustomâ, this is a name that probably wonât conflict with anything delivered in the future.
Next, create the following files in that new directory (âŠâŠ/mayan/apps/zzzcustom) with the following contents:
__init__.py:
from __future__ import unicode_literals
default_app_config = 'zzzcustom.apps.ZZZCustomApp'
apps.py:
from __future__ import unicode_literals
from django.utils.translation import ugettext_lazy as _
from common import MayanAppConfig
from common import menu_main
from tags.menus import menu_tags
from cabinets.menus import menu_cabinets
from document_states.links import link_workflow_list
from checkouts.links import link_checkout_list
class ZZZCustomApp(MayanAppConfig):
name = 'zzzcustom'
verbose_name = _('Custom Stuff')
def ready(self):
super(ZZZCustomApp, self).ready()
# Remove "Tags" links from main menu
menu_main.unbind_links(links=(menu_tags,),)
# Remove "Cabients" from main menu
menu_main.unbind_links(links=(menu_cabinets,),)
# Remove "Workflow" from main menu
menu_main.unbind_links(links=(link_workflow_list,),)
# Remove "Checkouts" from main menu
menu_main.unbind_links(links=(link_checkout_list,),)
You can comment out or remove calls to menu_main.unbind_links if you want to keep those options available.
2) Add the following to your settings/local.py:
INSTALLED_APPS += ('zzzcustom',)
At this point you should be able to start Mayan and no longer see the Tags, Cabinets, Workflow, and Checkouts menus.
So how does all this work?
The line in local.py adds the custom app into the list of installed apps. Mayan uses this to figure out what objects to load, so this makes it load the custom app.
The line in __init__.py is required by Django (which Mayan uses as its framework) to tell it what class to use to initialize the app.
Finally, apps.py has the code that actually initializes the custom app. The ready method within the configuration class (ZZZCustomApp) tells Mayanâs menu_main object to unbind various links. The link objects that are being unbound are imported from the various apps that provide them. Removing other items requires looking through the source of the app that provides them, figuring out how they are bound to the main menu, then writing code in the custom app to unbind them.
Why use a custom app for this? Simple - if you modify the delivered Mayan code, you have to remodify it every time you upgrade. By using a custom app it should survive upgrades and require no (or minimal) changes.
Hopefully this is enough to get everyone who wants to remove items from the main menu started.
Thanks,
-- Dave Kimmel
***@gmail.com
--
---
You received this message because you are subscribed to the Google Groups "Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mayan-edms+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
---
You received this message because you are subscribed to the Google Groups "Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mayan-edms+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.