Skip to content

Commit

Permalink
Upgrade demo project
Browse files Browse the repository at this point in the history
Add custom model permission to test app for a better coverage
minor enhancements
  • Loading branch information
RamezIssac committed Jul 24, 2023
1 parent fb5c6ad commit 54c75a8
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 12 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
language: python
python:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"

env:
- DJANGO=django==1.11.28
- DJANGO=django==2.2.12
- DJANGO=django==3.2
- DJANGO=django==4.0
- DJANGO=django==4.1
- DJANGO=django==4.2

before_install:
- wget https://github.com/mozilla/geckodriver/releases/download/v0.17.0/geckodriver-v0.17.0-linux64.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Features:
* Customize which apps, models to show in the permissions table. You can also set a exclude function for high-end customization.
* RTL ready, Bootstrap ready.
* Easy customize-able look.
* Python 2.7, 3.6, 3.7, 3.8, 3.9 , 3.10. Django 1.11, 2.1, 2.2, 3.0, 3.1, 3.2 , 4.0, 4.1.
* Python 2.7, 3.6, 3.7, 3.8, 3.9 , 3.10. Django 1.11, 2.1, 2.2, 3.0, 3.1, 3.2 , 4.0, 4.1, 4.2
* Default `FilteredSelectMultiple` widget will appear only if you have custom permissions that are not model related (ie directly created by code or hand)


Expand Down
4 changes: 2 additions & 2 deletions demo_proj/demo_proj/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.urls import path
from django.contrib import admin

urlpatterns = [
url(r'^admin/', admin.site.urls),
path('admin/', admin.site.urls),
]
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
Expand Down
9 changes: 5 additions & 4 deletions tabular_permissions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ def formfield_for_manytomany(self, db_field, request=None, **kwargs):

try:
UserAdminModel = admin.site._registry[User].__class__
except:
except: # pragma: no cover
UserAdminModel = DjUserAdmin

try:
GroupAdminModel = admin.site._registry[Group].__class__
except:
except: # pragma: no cover
GroupAdminModel = DjGroupAdmin


Expand All @@ -55,5 +55,6 @@ class TabularPermissionsGroupAdmin(GroupTabularPermissionsMixin, GroupAdminModel
admin.site.register(Group, TabularPermissionsGroupAdmin)

except:
raise ImproperlyConfigured('Please make sure that django.contrib.auth '
'comes before tabular_permissions in INSTALLED_APPS')
raise ImproperlyConfigured(
'Please make sure that django.contrib.auth (Or the app containing your custom User model) '
'comes before tabular_permissions in INSTALLED_APPS; Or set AUTO_IMPLEMENT to False in your settings.')
Empty file added tests/custom_models/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions tests/custom_models/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions tests/custom_models/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class CustomModelsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'custom_models'
Empty file.
10 changes: 10 additions & 0 deletions tests/custom_models/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.db import models


class ModelWithCustomPermissions(models.Model):
name = models.TextField()

class Meta:
permissions = [
("can_do_something", "Can do something"),
]
3 changes: 3 additions & 0 deletions tests/custom_models/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions tests/custom_models/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
1 change: 1 addition & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'django.contrib.sites',

'tabular_permissions',
"custom_models",

]

Expand Down
2 changes: 1 addition & 1 deletion tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


urlpatterns = [
path(r'^admin/', admin.site.urls),
path('admin/', admin.site.urls),
]


0 comments on commit 54c75a8

Please sign in to comment.