Skip to content

Commit

Permalink
Merge branch 'v2-vertical' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
darklow committed Dec 11, 2016
2 parents 1e78b7d + d6a220e commit b1bb56c
Show file tree
Hide file tree
Showing 39 changed files with 3,756 additions and 388 deletions.
2 changes: 1 addition & 1 deletion demo/demo/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CountryAdmin(admin.ModelAdmin):
list_display = ('name', 'code', 'continent', 'independence_day')
list_filter = ('continent',)
list_select_related = True
date_hierarchy = 'independence_day'
# date_hierarchy = 'independence_day'
inlines = (CityInline,)

# fields = ('name', 'continent', 'code', 'independence_day')
Expand Down
10 changes: 6 additions & 4 deletions demo/demo/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ class SuitConfig(DjangoSuitConfig):
ChildItem(model='demo.country'),
ChildItem(model='demo.continent'),
ChildItem(model='demo.showcase'),
]),
ChildItem('Custom view', url='/admin/custom/'),
], icon='fa fa-leaf'),
ParentItem('Integrations', children=[
ChildItem(model='demo.city'),
]),
ParentItem('Users', children=[
ChildItem(model='auth.user'),
ChildItem('User groups', 'auth.group'),
ChildItem('Custom page', url='/admin/custom/'),
]),
], icon='fa fa-users'),
ParentItem('Right Side Menu', children=[
ChildItem('Password change', url='admin:password_change'),
ChildItem('Open Google', url='http://google.com', target_blank=True),

], align_right=True),
], align_right=True, icon='fa fa-cog'),
)

layout = 'vertical'

def ready(self):
super(SuitConfig, self).ready()

Expand Down
5 changes: 5 additions & 0 deletions demo/demo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"""
from django.conf.urls import url
from django.contrib import admin
from django.views.generic import RedirectView

from . import views

urlpatterns = [
Expand All @@ -23,4 +25,7 @@
url(r'^admin/custom/$', views.custom_admin_view),

url(r'^admin/', admin.site.urls),

# Documentation url for menu documentation link
url(r'^admin/custom2/', RedirectView.as_view(url='http://djangosuit.com/support/'), name='django-admindocs-docroot'),
]
5 changes: 5 additions & 0 deletions demo/demo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

@staff_member_required
def custom_admin_view(request):
"""
If you're using multiple admin sites with independent views you'll need to set
current_app manually and use correct admin.site
# request.current_app = 'admin'
"""
context = admin.site.each_context(request)
context.update({
'title': 'Custom view',
Expand Down
Binary file added suit/.DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions suit/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class DjangoSuitConfig(AppConfig):
django_version = get_version()
version = VERSION

# Menu and header layout - horizontal or vertical
layout = 'horizontal'

# Set default list per page
list_per_page = 20

Expand Down
14 changes: 12 additions & 2 deletions suit/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.apps import apps
from django.template import VariableDoesNotExist
from suit.apps import DjangoSuitConfig


Expand All @@ -18,8 +19,9 @@ def get_config_instance(app_name=None):
#: :type: DjangoSuitConfig()
suit_config_cls = DjangoSuitConfig

def get_config(param=None, app_name=None):
suit_config = get_config_instance(app_name)

def get_config(param=None, request=None):
suit_config = get_config_instance(get_current_app(request) if request else None)
if param:
value = getattr(suit_config, param, None)
if value is None:
Expand All @@ -29,6 +31,14 @@ def get_config(param=None, app_name=None):
return suit_config


def get_current_app(request):
try:
return request.current_app
except (VariableDoesNotExist, AttributeError):
pass
return None


def set_config_value(name, value):
config = get_config()
# Store previous value to reset later if needed
Expand Down
15 changes: 8 additions & 7 deletions suit/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def _key(self):

class ParentItem(ChildItem):
def __init__(self, label=None, app=None, url=None, target_blank=False, permissions=None,
children=None, align_right=False, use_first_child_url=True):
children=None, align_right=False, use_first_child_url=True, icon=None):
super(ParentItem, self).__init__(label, None, url, target_blank, permissions)
self.user_children = children or []
self.children = []
self.align_right = align_right
self.icon = None
self.icon = icon
self.app = app
self.use_first_child_url = use_first_child_url

Expand All @@ -37,7 +37,7 @@ def _key(self):

class MenuManager(object):
def __init__(self, available_apps, context, request):
from .config import get_config_instance
from .config import get_config_instance, get_current_app

super(MenuManager, self).__init__()

Expand All @@ -47,7 +47,8 @@ def __init__(self, available_apps, context, request):

self.context = context
self.request = request
self.suit_config = get_config_instance(request.current_app)
self.current_app = get_current_app(request)
self.suit_config = get_config_instance(self.current_app)
self.user_menu = self.suit_config.menu
self.menu_items = None
self.aligned_right_menu_items = []
Expand Down Expand Up @@ -98,11 +99,11 @@ def build_menu(self):
if not self.parent_item_is_forbidden(parent_item, native_app):
menu_items.append(parent_item)

if parent_item.align_right:
if parent_item.align_right and self.suit_config.layout == 'horizontal':
self.aligned_right_menu_items.append(parent_item)

if self.suit_config.menu_show_home:
home_item = ParentItem(_('Home'), url='admin:index')
home_item = ParentItem(_('Home'), url='admin:index', icon='fa fa-home')
menu_items.insert(0, self.handle_user_url(home_item))

return self.mark_active(menu_items)
Expand Down Expand Up @@ -219,7 +220,7 @@ def handle_user_url(self, menu_item):
return menu_item
from django.core.urlresolvers import reverse, NoReverseMatch
try:
menu_item.url = reverse(menu_item.url, current_app=self.request.current_app)
menu_item.url = reverse(menu_item.url, current_app=self.current_app)
menu_item._url_name = menu_item.url
except NoReverseMatch:
menu_item.url = '#no-reverse-match'
Expand Down
5 changes: 5 additions & 0 deletions suit/sass/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@
@extend .text-semibold;
}
}
@mixin hide-text-indent() {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
9 changes: 8 additions & 1 deletion suit/sass/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ $link-color-bright: darken($link-color-brighter, 10%);
$link-color: darken($link-color-brighter, 20%);
$body-bg: #f1f1f1;
$inverse: #252830;
//$inverse: #292C3A;
$header-bg: $inverse;
$inverse-light: lighten($inverse, 10%);
$inverse-lighter: lighten($inverse, 15%);
$inverse-lightest: lighten($inverse, 25%);
$top-nav-bg: $inverse-light;
$top-nav-bg: saturate(lighten($inverse, 9%), 2%);
//$top-nav-bg: desaturate(#363B4D, 1%);
$header-color: #fff;
$header-muted-color: lighten($header-bg, 30%);

Expand Down Expand Up @@ -54,6 +56,8 @@ $grid-gutter-width-base: 1.875rem;
$header-padding-horizontal: $grid-gutter-width-base;
$header-padding-vertical: $grid-gutter-width-base/1.8;
$nav-padding-horizontal: $grid-gutter-width-base + .75rem;
$footer-height: 66px;
$vertical-menu-width: 230px;

// Buttons
// --------------------------------------------------
Expand Down Expand Up @@ -93,7 +97,10 @@ $form-label-bg: #fff;
// Cards
// --------------------------------------------------
$card-border-radius: 0;
$card-border-radius-inner: 0;
$card-border-color: transparent;
$card-cap-bg: $inverse-lightest;
$card-cap-color: #fff;


// Blockquotes
Expand Down
3 changes: 3 additions & 0 deletions suit/sass/components/_alerts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
margin: 1rem $grid-gutter-width-base 0;
li {
@extend .alert;
&:last-child {
margin-bottom: 0;
}
&.success {
@extend .alert-success;
}
Expand Down
74 changes: 63 additions & 11 deletions suit/sass/components/_breadcrumbs.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
.breadcrumbs {
padding: 1.5rem $nav-padding-horizontal 0;
font-size: $font-size-sm;
color: $header-muted-color;
body.change-list & {
display: none;
}
body.change-form & {
display: block;
position: relative;
z-index: 6;
li {
float: left;
}
position: relative;
li {
float: left;
}
a {
color: $link-color;
Expand All @@ -22,3 +14,63 @@
}
}
}
body.suit_layout_vertical {
#container {
> .breadcrumbs {
display: block;
position: absolute;
padding: 1.5rem $grid-gutter-width-base;
left: $vertical-menu-width;
}
> .messagelist {
display: none;
}
#content {
.breadcrumbs {
display: none;
}
.messagelist {
margin: 0 0 $grid-gutter-width-base/2 0;
}
}
}
/*&.change-form {
#container {
> .breadcrumbs {
display: none;
}
}
#content {
.breadcrumbs {
}
}
}*/
}

body.suit_layout_horizontal {
.breadcrumbs {
padding: 1.5rem $nav-padding-horizontal 0;
}
&.change-list {
.breadcrumbs {
display: none;
}
}
&.change-form {
#content {
.breadcrumbs {
display: none;
padding: 1.5rem 0;
position: relative;
z-index: 6;
li {
float: left;
}
}
.messagelist {
display: none;
}
}
}

}
5 changes: 4 additions & 1 deletion suit/sass/components/_cards.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// Cards should act like
.card {
@include suit-box-shadow();
border: none;
.card-header {
color: $card-cap-color;
}
}
2 changes: 1 addition & 1 deletion suit/sass/components/_confirmations.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
body.delete-confirmation {
#content {
.content-wrap {
display: block;
@extend .alert;
@extend .alert-danger;
Expand Down
2 changes: 1 addition & 1 deletion suit/sass/components/_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
$icon-ok: "\f00c";
$icon-remove: "\f00d";
$icon-cog: "\f013";
$icon-home: "\f013";
$icon-home: "\f015";
$icon-plus: "\f067";
$icon-plus-circle: "\f055";
$icon-pencil: "\f040";
Expand Down
2 changes: 1 addition & 1 deletion suit/sass/components/_widgets.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fieldset {
.float-xs-left {
margin-right: 1rem;
max-width: 75px;
max-height: 75px;
height: auto;
}
}
.widget-AdminSplitDateTime, .widget-AdminDateWidget, .widget-AdminTimeWidget {
Expand Down
12 changes: 9 additions & 3 deletions suit/sass/layout/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ body.change-form {
justify-content: flex-start;
align-content: flex-end;
align-items: flex-start;
> h1 {
.content-wrap {
body.dashboard & {
display: flex;
}
flex-basis: 100%;
&:first-child {
display: none;
> h1 {
flex-basis: 100%;
&:first-child {
display: none;
}
}
}

Expand Down

0 comments on commit b1bb56c

Please sign in to comment.