Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

**1.5 (June 28, 2018)**

* Improved support for Django 1.11, with initial support for 2.0

**1.4 (June 8, 2017)**

* New: localization for messages in admin. Russian locale available
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test:
DJANGO_SETTINGS_MODULE=locking.tests.settings django-admin.py collectstatic --link --noinput
DJANGO_SETTINGS_MODULE=locking.tests.settings django-admin.py test locking
DJANGO_SETTINGS_MODULE=tests.settings django-admin.py collectstatic --link --noinput
DJANGO_SETTINGS_MODULE=tests.settings django-admin.py test tests
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Prevents users from overwriting each others changes in Django.
Django Admin Locking is tested in the following environments

* Python (2.7, 3.4)
* Django (1.8, 1.9, 1.10)
* Django (1.8, 1.9, 1.10, 1.11)

## Installation

Expand Down
5 changes: 3 additions & 2 deletions locking/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ def get_queryset(self):

class Lock(models.Model):
id = models.CharField(max_length=15, primary_key=True)
locked_by = models.ForeignKey(getattr(settings, 'AUTH_USER_MODEL', 'auth.User'))
locked_by = models.ForeignKey(getattr(settings, 'AUTH_USER_MODEL', 'auth.User'),
on_delete=models.CASCADE)
date_expires = models.DateTimeField()
content_type = models.ForeignKey(ContentType)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')

Expand Down
42 changes: 22 additions & 20 deletions locking/static/locking/js/locking.admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,29 @@
$('.locking-status.locked').removeClass('locked').removeAttr('title');
for (var i = 0; i < data.length; i++) {
user = data[i]['locked_by'];
if (user['username'] === self.currentUser) {
lockedMessage = self.lockedByMeText;
lockedClass = "editing";
} else {
name = user['first_name'] + ' ' + user['last_name'];
if (name === ' ') {
name = user['username'];
if (user) {
if (user['username'] === self.currentUser) {
lockedMessage = self.lockedByMeText;
lockedClass = "editing";
} else {
name = user['first_name'] + ' ' + user['last_name'];
if (name === ' ') {
name = user['username'];
}
lockedMessage = self.lockedByUserText + ' ' + name;
if (user['email']){
lockedMessage += ' (' + user['email'] + ')';
}
lockedClass = "locked";
}
lockedMessage = self.lockedByUserText + ' ' + name;
if (user['email']){
lockedMessage += ' (' + user['email'] + ')';
}
lockedClass = "locked";
}
$('#locking-' + data[i]['object_id'])
.removeClass('locked editing')
.addClass(lockedClass)
.attr('title', lockedMessage)
.click(function () {
locking.cookies.set(self.cookieName, '1', 60 * 1000);
});
$('#locking-' + data[i]['object_id'])
.removeClass('locked editing')
.addClass(lockedClass)
.attr('title', lockedMessage)
.click(function () {
locking.cookies.set(self.cookieName, '1', 60 * 1000);
});
};
}
}});
};
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

setup(
name='django-admin-locking',
version='1.4',
version='1.5',
url='https://github.com/joshmaker/django-admin-locking/',
download_url='https://github.com/joshmaker/django-admin-locking/tarball/v1.4',
download_url='https://github.com/joshmaker/django-admin-locking/tarball/v1.5',
license='BSD',
description='Prevents users from overwriting each others changes in Django.',
author='Josh West',
Expand Down
3 changes: 2 additions & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@

MEDIA_URL = '/media/' # Avoids https://code.djangoproject.com/ticket/21451

MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
MIDDLEWARE_CLASSES = MIDDLEWARE

ROOT_URLCONF = 'tests.urls'

Expand Down