pep8
This commit is contained in:
parent
0ecf6d3dc9
commit
92ea48f89d
12 changed files with 55 additions and 47 deletions
|
@ -4,12 +4,12 @@ from django.forms.widgets import PasswordInput
|
||||||
from accounts.models import *
|
from accounts.models import *
|
||||||
|
|
||||||
|
|
||||||
__all__ = [ 'UserForm', 'GroupForm', 'TeamForm' ]
|
__all__ = ['UserForm', 'GroupForm', 'TeamForm']
|
||||||
|
|
||||||
|
|
||||||
UserForm = modelform_factory(User,
|
UserForm = modelform_factory(User,
|
||||||
fields=['username', 'first_name', 'last_name',
|
fields=['username', 'first_name',
|
||||||
'password', 'email', 'is_superuser'],
|
'last_name', 'password', 'email', 'is_superuser'],
|
||||||
widgets={'password': PasswordInput})
|
widgets={'password': PasswordInput})
|
||||||
GroupForm = modelform_factory(Group,
|
GroupForm = modelform_factory(Group,
|
||||||
fields=['name'])
|
fields=['name'])
|
||||||
|
|
|
@ -5,14 +5,14 @@ from django.contrib import auth
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
|
|
||||||
|
|
||||||
__all__ = [ 'User', 'Group', 'Team' ]
|
__all__ = ['User', 'Group', 'Team']
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class User(AbstractUser):
|
class User(AbstractUser):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = [ 'username' ]
|
ordering = ['username']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def teams(self):
|
def teams(self):
|
||||||
|
@ -45,7 +45,7 @@ class User(AbstractUser):
|
||||||
class Group(auth.models.Group):
|
class Group(auth.models.Group):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = [ 'name' ]
|
ordering = ['name']
|
||||||
proxy = True
|
proxy = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -57,7 +57,7 @@ class Group(auth.models.Group):
|
||||||
class Team(models.Model):
|
class Team(models.Model):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = [ 'name' ]
|
ordering = ['name']
|
||||||
|
|
||||||
name = models.CharField(max_length=128, unique=True)
|
name = models.CharField(max_length=128, unique=True)
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,8 @@ def group_add_user(request, group):
|
||||||
else:
|
else:
|
||||||
user.groups.add(group)
|
user.groups.add(group)
|
||||||
user.save()
|
user.save()
|
||||||
messages.success(request, 'User added to group successfully.')
|
messages.success(request,
|
||||||
|
'User added to group successfully.')
|
||||||
else:
|
else:
|
||||||
messages.error(request, 'User not found.')
|
messages.error(request, 'User not found.')
|
||||||
return redirect('show-group', group.id)
|
return redirect('show-group', group.id)
|
||||||
|
@ -160,12 +161,12 @@ def group_add_user(request, group):
|
||||||
if not term:
|
if not term:
|
||||||
return Http404()
|
return Http404()
|
||||||
query = Q(username__icontains=term) \
|
query = Q(username__icontains=term) \
|
||||||
| Q(first_name__icontains=term) \
|
| Q(first_name__icontains=term) \
|
||||||
| Q(last_name__icontains=term)
|
| Q(last_name__icontains=term)
|
||||||
users = User.objects.exclude(groups=group).filter(query)[:10]
|
users = User.objects.exclude(groups=group).filter(query)[:10]
|
||||||
response = []
|
response = []
|
||||||
for user in users:
|
for user in users:
|
||||||
response += [ {
|
response += [{
|
||||||
'label': user.username_and_fullname,
|
'label': user.username_and_fullname,
|
||||||
'value': user.username,
|
'value': user.username,
|
||||||
}]
|
}]
|
||||||
|
@ -249,7 +250,8 @@ def team_add_user(request, team):
|
||||||
else:
|
else:
|
||||||
team.users.add(user)
|
team.users.add(user)
|
||||||
team.save()
|
team.save()
|
||||||
messages.success(request, 'User added to team successfully.')
|
messages.success(request,
|
||||||
|
'User added to team successfully.')
|
||||||
else:
|
else:
|
||||||
messages.error(request, 'User not found.')
|
messages.error(request, 'User not found.')
|
||||||
request.session['team-tab'] = 'user'
|
request.session['team-tab'] = 'user'
|
||||||
|
@ -259,15 +261,15 @@ def team_add_user(request, team):
|
||||||
if not term:
|
if not term:
|
||||||
return Http404()
|
return Http404()
|
||||||
query = Q(username__icontains=term) \
|
query = Q(username__icontains=term) \
|
||||||
| Q(first_name__icontains=term) \
|
| Q(first_name__icontains=term) \
|
||||||
| Q(last_name__icontains=term)
|
| Q(last_name__icontains=term)
|
||||||
users = User.objects \
|
users = User.objects \
|
||||||
.exclude(groups__in=team.groups.all()) \
|
.exclude(groups__in=team.groups.all()) \
|
||||||
.exclude(id__in=team.users.values('id')) \
|
.exclude(id__in=team.users.values('id')) \
|
||||||
.filter(query)[:10]
|
.filter(query)[:10]
|
||||||
response = []
|
response = []
|
||||||
for user in users:
|
for user in users:
|
||||||
response += [ {
|
response += [{
|
||||||
'label': user.username_and_fullname,
|
'label': user.username_and_fullname,
|
||||||
'value': user.username,
|
'value': user.username,
|
||||||
}]
|
}]
|
||||||
|
@ -299,7 +301,8 @@ def team_add_group(request, team):
|
||||||
else:
|
else:
|
||||||
team.groups.add(group)
|
team.groups.add(group)
|
||||||
team.save()
|
team.save()
|
||||||
messages.success(request, 'Group added to team successfully.')
|
messages.success(request,
|
||||||
|
'Group added to team successfully.')
|
||||||
else:
|
else:
|
||||||
messages.error(request, 'Group not found.')
|
messages.error(request, 'Group not found.')
|
||||||
request.session['team-tab'] = 'group'
|
request.session['team-tab'] = 'group'
|
||||||
|
@ -309,11 +312,11 @@ def team_add_group(request, team):
|
||||||
if not term:
|
if not term:
|
||||||
return Http404()
|
return Http404()
|
||||||
groups = Group.objects \
|
groups = Group.objects \
|
||||||
.exclude(id__in=team.groups.values('id')) \
|
.exclude(id__in=team.groups.values('id')) \
|
||||||
.filter(name__icontains=term)[:10]
|
.filter(name__icontains=term)[:10]
|
||||||
response = []
|
response = []
|
||||||
for group in groups:
|
for group in groups:
|
||||||
response += [ {
|
response += [{
|
||||||
'label': group.name,
|
'label': group.name,
|
||||||
'value': group.name,
|
'value': group.name,
|
||||||
}]
|
}]
|
||||||
|
|
|
@ -7,7 +7,7 @@ from permissions.models import PermissionModel
|
||||||
from accounts.models import *
|
from accounts.models import *
|
||||||
|
|
||||||
|
|
||||||
__all__ = [ 'GlobalPermissionForm', 'ProjectPermissionForm' ]
|
__all__ = ['GlobalPermissionForm', 'ProjectPermissionForm']
|
||||||
|
|
||||||
|
|
||||||
class PermissionForm(forms.ModelForm):
|
class PermissionForm(forms.ModelForm):
|
||||||
|
@ -52,9 +52,9 @@ class GlobalPermissionForm(PermissionForm):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = GlobalPermission
|
model = GlobalPermission
|
||||||
fields = [ 'grantee_type', 'grantee_id' ]
|
fields = ['grantee_type', 'grantee_id']
|
||||||
widgets = {
|
widgets = {
|
||||||
'grantee_id': HiddenInput,
|
'grantee_id': HiddenInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class ProjectPermissionForm(PermissionForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ProjectPermission
|
model = ProjectPermission
|
||||||
# project is required for the unicity check
|
# project is required for the unicity check
|
||||||
fields = [ 'project', 'grantee_type', 'grantee_id' ]
|
fields = ['project', 'grantee_type', 'grantee_id']
|
||||||
widgets = {
|
widgets = {
|
||||||
'project': HiddenInput,
|
'project': HiddenInput,
|
||||||
'grantee_id': HiddenInput,
|
'grantee_id': HiddenInput,
|
||||||
|
|
|
@ -7,7 +7,7 @@ from tracker.models import Project
|
||||||
from accounts.models import *
|
from accounts.models import *
|
||||||
|
|
||||||
|
|
||||||
__all__ = [ 'GlobalPermission', 'ProjectPermission' ]
|
__all__ = ['GlobalPermission', 'ProjectPermission']
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
|
@ -82,7 +82,7 @@ class PermissionModel(models.Model):
|
||||||
class GlobalPermission(PermissionModel):
|
class GlobalPermission(PermissionModel):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ( 'grantee_type', 'grantee_id' )
|
unique_together = ('grantee_type', 'grantee_id')
|
||||||
|
|
||||||
# Global permissions
|
# Global permissions
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ class GlobalPermission(PermissionModel):
|
||||||
class ProjectPermission(PermissionModel):
|
class ProjectPermission(PermissionModel):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ( 'project', 'grantee_type', 'grantee_id' )
|
unique_together = ('project', 'grantee_type', 'grantee_id')
|
||||||
|
|
||||||
project = models.ForeignKey(Project, related_name='permissions')
|
project = models.ForeignKey(Project, related_name='permissions')
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ on the foreign object id, we can rely on database cascade deletion to delete
|
||||||
outaded permissions and we have to do it our-self.
|
outaded permissions and we have to do it our-self.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@receiver(pre_delete, sender=User, dispatch_uid="clean_user_perms")
|
@receiver(pre_delete, sender=User, dispatch_uid="clean_user_perms")
|
||||||
def clean_user_perms(sender, instance, **kwargs):
|
def clean_user_perms(sender, instance, **kwargs):
|
||||||
# Clean global permissions
|
# Clean global permissions
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
from ponytracker.settings import *
|
from ponytracker.settings import *
|
||||||
|
|
||||||
|
|
||||||
### Uncomment to use celery worker
|
# # Uncomment to use celery worker
|
||||||
### Don't forget to install a broker:
|
# # Don't forget to install a broker:
|
||||||
### # http://docs.celeryproject.org/en/latest/getting-started/brokers/index.html#broker-overview
|
# # http://docs.celeryproject.org/en/latest/getting-started/brokers/index.html#broker-overview
|
||||||
#INSTALLED_APPS += ('djcelery',)
|
# INSTALLED_APPS += ('djcelery',)
|
||||||
#import djcelery
|
# import djcelery
|
||||||
#djcelery.setup_loader()
|
# djcelery.setup_loader()
|
||||||
|
|
||||||
SECRET_KEY='CHANGE ME'
|
SECRET_KEY = 'CHANGE ME'
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
|
||||||
|
|
|
@ -143,19 +143,22 @@ BOOTSTRAP3 = {
|
||||||
#'base_url': '//netdna.bootstrapcdn.com/bootstrap/3.2.0/',
|
#'base_url': '//netdna.bootstrapcdn.com/bootstrap/3.2.0/',
|
||||||
'base_url': STATIC_URL,
|
'base_url': STATIC_URL,
|
||||||
|
|
||||||
# The complete URL to the Bootstrap CSS file (None means derive it from base_url)
|
# The complete URL to the Bootstrap CSS file
|
||||||
|
# (None means derive it from base_url)
|
||||||
'css_url': None,
|
'css_url': None,
|
||||||
|
|
||||||
# The complete URL to the Bootstrap CSS file (None means no theme)
|
# The complete URL to the Bootstrap CSS file
|
||||||
|
# (None means no theme)
|
||||||
'theme_url': None,
|
'theme_url': None,
|
||||||
|
|
||||||
# The complete URL to the Bootstrap JavaScript file (None means derive it from base_url)
|
# The complete URL to the Bootstrap JavaScript file
|
||||||
|
# (None means derive it from base_url)
|
||||||
'javascript_url': None,
|
'javascript_url': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Celery configuration
|
# Celery configuration
|
||||||
BROKER_URL = 'redis://localhost:6379/0'
|
BROKER_URL = 'redis://localhost:6379/0'
|
||||||
CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend'
|
CELERY_RESULT_BACKEND = 'djcelery.backends.database:DatabaseBackend'
|
||||||
CELERY_ACCEPT_CONTENT = ['json']
|
CELERY_ACCEPT_CONTENT = ['json']
|
||||||
CELERY_TASK_SERIALIZER = 'json'
|
CELERY_TASK_SERIALIZER = 'json'
|
||||||
CELERY_RESULT_SERIALIZER = 'json'
|
CELERY_RESULT_SERIALIZER = 'json'
|
||||||
|
|
4
tox.ini
4
tox.ini
|
@ -1,3 +1,3 @@
|
||||||
[pep8]
|
[pep8]
|
||||||
exclude=env,issue/migrations,issue/urls.py
|
exclude=env,*/migrations,*/urls.py,doc
|
||||||
ignore=E128
|
ignore=E128,E265
|
||||||
|
|
|
@ -16,7 +16,8 @@ class ProjectForm(forms.ModelForm):
|
||||||
model = Project
|
model = Project
|
||||||
fields = ['display_name', 'name', 'description', 'access']
|
fields = ['display_name', 'name', 'description', 'access']
|
||||||
help_texts = {
|
help_texts = {
|
||||||
'name': 'Warning: if you change this value, this will break existing URLs.'
|
'name': 'Warning: if you change this value, '
|
||||||
|
'this will break existing URLs.'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ from permissions.models import PermissionModel as PermModel
|
||||||
|
|
||||||
|
|
||||||
# This middleware protect only views of the following modules
|
# This middleware protect only views of the following modules
|
||||||
modules = [ 'accounts.views', 'permissions.views', 'tracker.views' ]
|
modules = ['accounts.views', 'permissions.views', 'tracker.views']
|
||||||
|
|
||||||
|
|
||||||
class ProjectMiddleware:
|
class ProjectMiddleware:
|
||||||
|
|
|
@ -14,14 +14,14 @@ from accounts.models import User
|
||||||
from tracker.templatetags.tracker_tags import *
|
from tracker.templatetags.tracker_tags import *
|
||||||
|
|
||||||
|
|
||||||
__all__ = [ 'Project', 'Issue', 'Label', 'Milestone', 'Event' ]
|
__all__ = ['Project', 'Issue', 'Label', 'Milestone', 'Event']
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class Project(models.Model):
|
class Project(models.Model):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = [ 'name' ]
|
ordering = ['name']
|
||||||
|
|
||||||
ACCESS_PUBLIC = 1
|
ACCESS_PUBLIC = 1
|
||||||
ACCESS_REGISTERED = 2
|
ACCESS_REGISTERED = 2
|
||||||
|
@ -81,7 +81,7 @@ class Label(models.Model):
|
||||||
class Milestone(models.Model):
|
class Milestone(models.Model):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = [ 'due_date' ]
|
ordering = ['due_date']
|
||||||
|
|
||||||
name_validator = RegexValidator(regex='^[a-z0-9_.-]+$',
|
name_validator = RegexValidator(regex='^[a-z0-9_.-]+$',
|
||||||
message="Please enter only lowercase characters, number, "
|
message="Please enter only lowercase characters, number, "
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue