Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #41 from freshlimestudio/master

Small fixes for admin
  • Loading branch information...
commit 4cb7c35e4f41e0a1a0a2a23b1f3883e06a00b975 2 parents f044eca + 00baf51
Kristian Øllegaard authored

Showing 2 changed files with 23 additions and 10 deletions. Show diff stats Hide diff stats

  1. +4 1 nani/admin.py
  2. +19 9 nani/tests/limit_choices_to.py
5 nani/admin.py
@@ -273,10 +273,13 @@ def delete_translation(self, request, object_id, language_code):
273 273 "perms_lacking": perms_needed,
274 274 "protected": protected,
275 275 "opts": opts,
276   - "root_path": self.admin_site.root_path,
277 276 "app_label": app_label,
278 277 }
279 278
  279 + # in django > 1.4 root_path is removed
  280 + if hasattr(self.admin_site, 'root_path'):
  281 + context.update({"root_path": self.admin_site.root_path})
  282 +
280 283 return render_to_response(self.delete_confirmation_template or [
281 284 "admin/%s/%s/delete_confirmation.html" % (app_label, opts.object_name.lower()),
282 285 "admin/%s/delete_confirmation.html" % app_label,
28 nani/tests/limit_choices_to.py
... ... @@ -1,20 +1,27 @@
1 1 # -*- coding: utf-8 -*-
2 2 from django.contrib import admin
  3 +from django.contrib.auth.models import User
3 4
4 5 from nani.test_utils.testcase import NaniTestCase
5   -from nani.test_utils.fixtures import (
6   - TwoTranslatedNormalMixin,
7   - SuperuserMixin,
8   -)
  6 +from nani.test_utils.fixtures import TwoTranslatedNormalMixin
9 7
10 8 from testproject.app.models import LimitedChoice
11 9
12 10
13   -class LimitChoicesToTests(
14   - NaniTestCase,
15   - TwoTranslatedNormalMixin,
16   - SuperuserMixin
17   -):
  11 +class LimitChoicesToTests(NaniTestCase, TwoTranslatedNormalMixin):
  12 + def create_fixtures(self):
  13 + su = User(
  14 + email='admin@admin.com',
  15 + is_staff=True,
  16 + is_superuser=True,
  17 + is_active=True,
  18 + username='admin',
  19 + )
  20 + su.set_password('admin')
  21 + su.save()
  22 + self.user = su
  23 + super(LimitChoicesToTests, self).create_fixtures()
  24 +
18 25 def test_limit_choices_to(self):
19 26 """
20 27 Checks if limit_choices_to works on ForeignKey and ManyToManyField.
@@ -33,6 +40,9 @@ def test_limit_choices_to(self):
33 40 # otherwise admin won't let us in
34 41 get_request.session = self.client.session
35 42
  43 + # in django 1.4 request.user is required
  44 + get_request.user = self.user
  45 +
36 46 # Let's construct the relevant admin form...
37 47 Form = limited_choice_admin.get_form(get_request)
38 48 form = Form()

0 comments on commit 4cb7c35

Please sign in to comment.
Something went wrong with that request. Please try again.