Skip to content

Commit

Permalink
Rosetta at admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
scream4ik committed Dec 13, 2016
1 parent d89248e commit 69a3059
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ testproject/src/
testproject/.coverage
.tox
.eggs

.idea
1 change: 1 addition & 0 deletions rosetta/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
VERSION = (0, 7, 13)
default_app_config = "rosetta.apps.RosettaAppConfig"


def get_version(svn=False, limit=3):
Expand Down
40 changes: 40 additions & 0 deletions rosetta/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from django.apps import AppConfig
from django.views.decorators.cache import never_cache
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _

from rosetta.conf import settings as rosetta_settings


class RosettaAppConfig(AppConfig):
name = 'rosetta'

def ready(self):
from django.contrib import admin
from django.contrib.admin import sites

class RosettaAdminSite(admin.AdminSite):
@never_cache
def index(self, request, extra_context=None):
resp = super(RosettaAdminSite, self).index(request,
extra_context)
app_dict = {
'app_url': reverse('rosetta-home'),
'models': [
{
'admin_url': reverse('rosetta-home'),
'name': _('Browse'),
'add_url': None
},
],
'has_module_perms': True,
'name': _('Transplations'),
'app_label': 'rosetta'
}
resp.context_data['app_list'].append(app_dict)
return resp

if rosetta_settings.SHOW_AT_ADMIN_PANEL:
rosetta = RosettaAdminSite()
admin.site = rosetta
sites.site = rosetta
2 changes: 2 additions & 0 deletions rosetta/conf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@

# Determines whether the MO file is automatically compiled when the PO file is saved.
AUTO_COMPILE = getattr(settings, 'ROSETTA_AUTO_COMPILE', True)

SHOW_AT_ADMIN_PANEL = getattr(settings, 'SHOW_AT_ADMIN_PANEL', False)

0 comments on commit 69a3059

Please sign in to comment.