This is awesome. Thanks Dave.

Em domingo, 1 de outubro de 2017 12:31:11 UTC-3, David Kimmel escreveu:
>
> 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
>    [email protected] <javascript:>
>
>
>
>

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to