[Mayan EDMS: 2147] Removing stuff from the main menu - the definitive guide

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Mayan EDMS: 2147] Removing stuff from the main menu - the definitive guide

Dave Kimmel
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
   [hidden email]



--

---
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

[Mayan EDMS: 2149] Re: Removing stuff from the main menu - the definitive guide

Diego R.
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
   <a href="javascript:" target="_blank" gdf-obfuscated-mailto="n_WW6SvoAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">davidj...@...



--

---
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

[Mayan EDMS: 2151] Re: Removing stuff from the main menu - the definitive guide

Diego R.
BTW If you want to remove the Dashboard Widgets, just add this to David's example:

from common.dashboards import dashboard_main
from documents.dashboard_widgets import widget_total_documents
from documents.dashboard_widgets import widget_document_types
from documents.dashboard_widgets import widget_documents_in_trash
from documents.dashboard_widgets import widget_new_documents_this_month
from documents.dashboard_widgets import widget_pages_per_month
from checkouts.dashboard_widgets import widget_checkouts

dashboard_main.remove_widget(widget=widget_total_documents)
dashboard_main.remove_widget(widget=widget_document_types)
dashboard_main.remove_widget(widget=widget_documents_in_trash)
dashboard_main.remove_widget(widget=widget_new_documents_this_month)
dashboard_main.remove_widget(widget=widget_pages_per_month)
dashboard_main.remove_widget(widget=widget_checkouts)



Em segunda-feira, 2 de outubro de 2017 18:10:45 UTC-3, Diego R. escreveu:
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
   [hidden email]



--

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