Skip to main content

Simple navbar classes for clinic/edc

Project description

pypi travis coverage

edc_navbar

Simple Navbar class for edc

Installation

Include edc_navbar.apps.AppConfig in INSTALLED_APPS.

Overiew

Navbars are declared in your apps navbars.py and will be autodiscovered by edc_navbar and stored in the site global site_navbars.

By default, a basic navbar is added to the site global. For it to load you need to define the named urls for home_url, administration_url and logout_url in your main project urls.py. The named urls defined in the default navbar do not include a namespace.

For example, in the “main” project app urls.py:

urlpatterns = [
    ...
    path('login', LoginView.as_view(), name='login_url'),
    path('logout', LogoutView.as_view(
        pattern_name='login_url'), name='logout_url'),
    path('admininistration/', AdministrationView.as_view(),
         name='administration_url'),
    path('', HomeView.as_view(manual_revision='1.0'), name='home_url'),
    ...
    ]

You can change the default navbar to another navbar by setting settings.DEFAULT_NAVBAR to the name of your custom navbar. You will need to declare and register your custom navbar manually. See edc_navbar.navbars.

Declaring and registering a navbar

A navbar is defined and registered to the site global in the navbars.py module of each app that needs a navbar.

An example navbars.py:

from edc_navbar import NavbarItem, site_navbars, Navbar

url_namespace = 'edc_pharmacy_dashboard'

# instantiate a Navbar
pharmacy_dashboard = Navbar(name='pharmacy_dashboard')

# add items to the navbar
pharmacy_dashboard.append_item(
    NavbarItem(
        name='prescribe',
        title='Prescribe',
        label='prescribe',
        glyphicon='glyphicon-edit',
        url_name=f'{url_namespace}:prescribe_listboard_url'))

pharmacy_dashboard.append_item(
    NavbarItem(
        name='dispense',
        title='Dispense',
        label='dispense',
        glyphicon='glyphicon-share',
        url_name=f'{url_namespace}:dispense_listboard_url'))

# register the navbar to the site
site_navbars.register(pharmacy_dashboard)

Accessing the navbar in your views

Next, add NavbarViewMixin to your views and set the navbar by name. The navbar will be rendered to string and added to the view context.

from edc_navbar import NavbarViewMixin

class HomeView(EdcBaseViewMixin, NavbarViewMixin, TemplateView):

    navbar_name = 'pharmacy_dashboard'
    navbar_selected_item = 'prescribe'

Rendering Navbar items

The default template for NavbarItem is navbar_item.html. You can declare a custom template on the NavbarItem.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edc_navbar-0.1.2.macosx-10.13-x86_64.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

edc_navbar-0.1.2-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file edc_navbar-0.1.2.macosx-10.13-x86_64.tar.gz.

File metadata

File hashes

Hashes for edc_navbar-0.1.2.macosx-10.13-x86_64.tar.gz
Algorithm Hash digest
SHA256 d17770ef005d1eb982a0fff48631bfab76b91106b9317c2ad232c089be75bdab
MD5 839ad27b409a07baf2c9faa6de7b95b0
BLAKE2b-256 c62a4a1a30ac1b1842011f1f6989b115054b6ccf95261a4023c68ac4bf1f8c27

See more details on using hashes here.

File details

Details for the file edc_navbar-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for edc_navbar-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 018cbf6d5ced49f7a1573d9ba82e88ab4b9ea6f3fd4d1181d74d451e3794c261
MD5 0577e37cac3787a5f5bf85b7ea2b839b
BLAKE2b-256 15c4f6b33206e6d9071fd1e3dcb3342930c0726b44a6155e7e7068e8f7637e5e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page