Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
zts0813 committed Mar 24, 2016
1 parent 3f128ca commit 0a91a60
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ language: python
python:
- "2.7"
install: "pip install -r requirements.txt --use-mirrors"
script: "cd tests/ && python runtests.py"
script: "cd tests/ && python runtests.py base view_base"
1 change: 1 addition & 0 deletions demo_app/demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.core.context_processors.i18n',
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
Expand Down
4 changes: 1 addition & 3 deletions tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ def setup(verbosity, test_labels):
# this module and add it to the list to test.
if not test_labels or module_name in test_labels_set:
if verbosity >= 2:
print "Importing application %s" % module_name
print("Importing application %s" % module_name)
#mod = load_app(module_label)
#TODO by gkiwi @2016-03-21 02:48:12

app_config = AppConfig.create(module_label)
app_config.import_models(apps.all_models[app_config.label])
apps.app_configs[app_config.label] = app_config
Expand Down Expand Up @@ -172,7 +171,6 @@ def django_tests(verbosity, interactive, failfast, test_labels):

if options.liveserver is not None:
os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = options.liveserver

failures = django_tests(int(options.verbosity), options.interactive,
options.failfast, args)
if failures:
Expand Down
22 changes: 16 additions & 6 deletions xadmin/plugins/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@
from django import forms
from django.db import models
from django.template import loader
from formtools.wizard.storage import get_storage
from formtools.wizard.forms import ManagementForm
from formtools.wizard.views import StepsHelper
try:
from formtools.wizard.storage import get_storage
from formtools.wizard.forms import ManagementForm
from formtools.wizard.views import StepsHelper
except:
##work for django<1.8
from django.contrib.formtools.wizard.storage import get_storage
from django.contrib.formtools.wizard.forms import ManagementForm
from django.contrib.formtools.wizard.views import StepsHelper

from django.utils.module_loading import import_string
from django.forms import ValidationError
from django.forms.models import modelform_factory

from xadmin.sites import site
from xadmin.views import BaseAdminPlugin, ModelFormAdminView

Expand All @@ -22,7 +31,7 @@ class WizardFormPlugin(BaseAdminPlugin):
wizard_form_list = None
wizard_for_update = False

storage_name = 'django.contrib.formtools.wizard.storage.session.SessionStorage'
storage_name = 'formtools.wizard.storage.session.SessionStorage'
form_list = None
initial_dict = None
instance_dict = None
Expand Down Expand Up @@ -84,6 +93,7 @@ def prepare_form(self, __):
# Check if form was refreshed
management_form = ManagementForm(
self.request.POST, prefix=self.prefix)

if not management_form.is_valid():
raise ValidationError(
'ManagementForm data is missing or has been tampered.')
Expand Down Expand Up @@ -306,13 +316,13 @@ def block_before_fieldsets(self, context, nodes):
'current_step': self.steps.current,
}),
}
nodes.append(loader.render_to_string('xadmin/blocks/model_form.before_fieldsets.wizard.html', context_instance=context))
nodes.append(loader.render_to_string('xadmin/blocks/model_form.before_fieldsets.wizard.html'))

def block_submit_line(self, context, nodes):
context.update(dict(self.storage.extra_data))
context['wizard'] = {
'steps': self.steps
}
nodes.append(loader.render_to_string('xadmin/blocks/model_form.submit_line.wizard.html', context_instance=context))
nodes.append(loader.render_to_string('xadmin/blocks/model_form.submit_line.wizard.html'))

site.register_plugin(WizardFormPlugin, ModelFormAdminView)
4 changes: 2 additions & 2 deletions xadmin/templates/xadmin/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
{{ media.css }}
{% block extrastyle %}{% endblock %}
{% vendor 'jquery.js' %}
{% vendor 'jquery-ui-sortable.js' 'bootstrap.js' 'xadmin.main.js' 'xadmin.responsive.js' %}
{{ media.js }}
{% url 'xadmin:index' as indexurl %}
<script type="text/javascript">
window.__admin_media_prefix__ = "{% filter escapejs %}{% static "xadmin/" %}{% endfilter %}";
Expand All @@ -35,8 +37,6 @@
{% block content %}{% endblock content %}
</div>
{% endblock body %}
{% vendor 'jquery-ui-sortable.js' 'bootstrap.js' 'xadmin.main.js' 'xadmin.responsive.js' %}
{{ media.js }}
{% block extrabody %}{% endblock %}
{% view_block 'extrabody' %}
</body>
Expand Down
2 changes: 1 addition & 1 deletion xadmin/templates/xadmin/blocks/comm.top.setlang.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
if(topmenu.data('bs.collapse')) topmenu.collapse('hide');
})
})
</script>
</script>
2 changes: 1 addition & 1 deletion xadmin/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def render_response(self, content, response_type='json'):
return HttpResponse(content)

def template_response(self, template, context):
return TemplateResponse(self.request, template, context, current_app=self.admin_site.name)
return TemplateResponse(self.request, template, context)

def message_user(self, message, level='info'):
"""
Expand Down

0 comments on commit 0a91a60

Please sign in to comment.