Skip to content

Commit

Permalink
Merge remote-tracking branch 'sshwsfc/master' -- update
Browse files Browse the repository at this point in the history
  • Loading branch information
fxiao committed Nov 20, 2013
2 parents fbe3338 + 4b28ccf commit 6138161
Show file tree
Hide file tree
Showing 88 changed files with 8,206 additions and 2,386 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ nosetests.xml
.c9revisions
.settings
xadmin/static/xadmin/components/
xadmin/static/xadmin/bower_components/

.idea
*~
demo_app/data.db
13 changes: 6 additions & 7 deletions demo_app/app/adminx.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import xadmin
from xadmin import views
from models import *
from xadmin.layout import *

from models import IDC, Host, MaintainLog, HostGroup, AccessRecord
from xadmin.layout import Main, TabHolder, Tab, Fieldset, Row, Col, AppendedText, Side
from xadmin.plugins.inline import Inline
from xadmin.plugins.batch import BatchChangeAction

Expand Down Expand Up @@ -30,8 +29,8 @@ class BaseSetting(object):


class GolbeSetting(object):
globe_search_models = [Host, IDC]
globe_models_icon = {
global_search_models = [Host, IDC]
global_models_icon = {
Host: 'laptop', IDC: 'cloud'
}
xadmin.site.register(views.CommAdminView, GolbeSetting)
Expand Down Expand Up @@ -90,14 +89,14 @@ def open_web(self, instance):
form_layout = (
Main(
TabHolder(
Tab('Comm Fiels',
Tab('Comm Fields',
Fieldset('Company data',
'name', 'idc',
description="some comm fields, required"
),
Inline(MaintainLog),
),
Tab('Extend Fiedls',
Tab('Extend Fields',
Fieldset('Contact details',
'service_type',
Row('brand', 'model'),
Expand Down
38 changes: 19 additions & 19 deletions demo_app/app/models.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
from django.db import models


class IDC(models.Model):
name = models.CharField(max_length=64)
description = models.TextField()

contact = models.CharField(max_length=32)
telphone = models.CharField(max_length=32)
address = models.CharField(max_length=128)
customer_id = models.CharField(max_length=128)

create_time = models.DateField(auto_now=True)

def __unicode__(self):
return self.name

class Meta:
verbose_name = u"IDC"
verbose_name_plural = verbose_name

SERVER_STATUS = (
(0, u"Normal"),
(1, u"Down"),
Expand All @@ -38,8 +20,26 @@ class Meta:
)


class Host(models.Model):
class IDC(models.Model):
name = models.CharField(max_length=64)
description = models.TextField()

contact = models.CharField(max_length=32)
telphone = models.CharField(max_length=32)
address = models.CharField(max_length=128)
customer_id = models.CharField(max_length=128)

create_time = models.DateField(auto_now=True)

def __unicode__(self):
return self.name

class Meta:
verbose_name = u"IDC"
verbose_name_plural = verbose_name


class Host(models.Model):
idc = models.ForeignKey(IDC)
name = models.CharField(max_length=64)
nagios_name = models.CharField(u"Nagios Host ID", max_length=64, blank=True, null=True)
Expand Down
Binary file modified demo_app/data.db
Binary file not shown.
2 changes: 1 addition & 1 deletion demo_app/demo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xadmin.autodiscover()

# from xadmin.plugins import xversion
# xversion.registe_models()
# xversion.register_models()

urlpatterns = patterns('',
url(r'', include(xadmin.site.urls)),
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
django>=1.4
django>=1.5
django-crispy-forms>=1.4.0
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python
from setuptools import setup, find_packages
from setuptools import setup

# version_tuple = __import__('xadmin.version').VERSION
# version = ".".join([str(v) for v in version_tuple])

setup(
name='django-xadmin',
version='0.4.0',
version='0.4.2',
description='Drop-in replacement of Django admin comes with lots of goodies, fully extensible with plugin support, pretty UI based on Twitter Bootstrap.',
long_description=open('README.rst').read(),
author='sshwsfc',
Expand All @@ -18,7 +18,7 @@
include_package_data=True,
install_requires=[
'setuptools',
'django>=1.4',
'django>=1.5',
'django-crispy-forms>=1.4.0',
],
extras_require={
Expand Down
4 changes: 3 additions & 1 deletion tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import tempfile

TEST_ROOT = os.path.realpath(os.path.dirname(__file__))
RUNTESTS_DIR = os.path.join(TEST_ROOT, 'xtests')

sys.path.insert(0, os.path.join(TEST_ROOT, os.pardir))
sys.path.insert(0, RUNTESTS_DIR)

RUNTESTS_DIR = os.path.join(TEST_ROOT, 'xtests')
TEST_TEMPLATE_DIR = 'templates'
TEMP_DIR = tempfile.mkdtemp(prefix='django_')
os.environ['DJANGO_TEST_TEMP_DIR'] = TEMP_DIR
Expand Down
4 changes: 2 additions & 2 deletions tests/xtests/view_base/adminx.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TestBaseView(BaseAdminView):
pass

class TestCommView(CommAdminView):
globe_models_icon = {ModelB: 'test'}
global_models_icon = {ModelB: 'test'}

class TestAView(BaseAdminView):
pass
Expand All @@ -27,4 +27,4 @@ class OptionA(object):
site.register_view(r"^test/a$", TestAView, 'test_a')

site.register(ModelA, ModelAAdmin)
site.register(ModelB)
site.register(ModelB)
6 changes: 4 additions & 2 deletions xadmin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from xadmin.sites import AdminSite, site

VERSION = [0,4,0]
VERSION = [0,4,2]


class Settings(object):
pass


def autodiscover():
"""
Auto-discover INSTALLED_APPS admin.py modules and fail silently when
Expand All @@ -21,7 +23,7 @@ def autodiscover():
"textinput": "textinput textInput form-control",
"fileinput": "fileinput fileUpload form-control",
"passwordinput": "textinput textInput form-control",
})
})

from xadmin.views import register_builtin_views
register_builtin_views(site)
Expand Down
1 change: 0 additions & 1 deletion xadmin/adminx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import xadmin
from xadmin import views
from models import UserSettings
from xadmin.layout import *

Expand Down
13 changes: 9 additions & 4 deletions xadmin/filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import datetime

from django.db import models
from django.core.exceptions import ImproperlyConfigured
from django.utils.encoding import smart_unicode
Expand All @@ -8,16 +6,17 @@
from django.template.loader import get_template
from django.template.context import Context
from django.utils.safestring import mark_safe
from django.utils.html import escape
from django.utils.html import escape,format_html
from django.utils.text import Truncator

from xadmin.views.list import EMPTY_CHANGELIST_VALUE
import datetime

FILTER_PREFIX = '_p_'
SEARCH_VAR = '_q_'

from util import (get_model_from_relation,
reverse_field_path, get_limit_choices_to_from_path, prepare_lookup_value)
reverse_field_path, get_limit_choices_to_from_path, prepare_lookup_value)


class BaseFilter(object):
Expand Down Expand Up @@ -335,6 +334,11 @@ def __init__(self, field, request, params, model, model_admin, field_path):
self.search_url = model_admin.get_admin_url('%s_%s_changelist' % (
other_model._meta.app_label, other_model._meta.module_name))
self.label = self.label_for_value(other_model, rel_name, self.lookup_exact_val) if self.lookup_exact_val else ""
self.choices = '?'
if field.rel.limit_choices_to:
for i in list(field.rel.limit_choices_to):
self.choices += "&_p_%s=%s" % (i, field.rel.limit_choices_to[i])
self.choices = format_html(self.choices)

def label_for_value(self, other_model, rel_name, value):
try:
Expand All @@ -347,6 +351,7 @@ def get_context(self):
context = super(RelatedFieldSearchFilter, self).get_context()
context['search_url'] = self.search_url
context['label'] = self.label
context['choices'] = self.choices
return context


Expand Down
Binary file modified xadmin/locale/de_DE/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 6138161

Please sign in to comment.