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 *
|
||||
|
||||
|
||||
__all__ = [ 'UserForm', 'GroupForm', 'TeamForm' ]
|
||||
__all__ = ['UserForm', 'GroupForm', 'TeamForm']
|
||||
|
||||
|
||||
UserForm = modelform_factory(User,
|
||||
fields=['username', 'first_name', 'last_name',
|
||||
'password', 'email', 'is_superuser'],
|
||||
fields=['username', 'first_name',
|
||||
'last_name', 'password', 'email', 'is_superuser'],
|
||||
widgets={'password': PasswordInput})
|
||||
GroupForm = modelform_factory(Group,
|
||||
fields=['name'])
|
||||
|
|
|
@ -5,14 +5,14 @@ from django.contrib import auth
|
|||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
|
||||
__all__ = [ 'User', 'Group', 'Team' ]
|
||||
__all__ = ['User', 'Group', 'Team']
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class User(AbstractUser):
|
||||
|
||||
class Meta:
|
||||
ordering = [ 'username' ]
|
||||
ordering = ['username']
|
||||
|
||||
@property
|
||||
def teams(self):
|
||||
|
@ -45,7 +45,7 @@ class User(AbstractUser):
|
|||
class Group(auth.models.Group):
|
||||
|
||||
class Meta:
|
||||
ordering = [ 'name' ]
|
||||
ordering = ['name']
|
||||
proxy = True
|
||||
|
||||
@property
|
||||
|
@ -57,7 +57,7 @@ class Group(auth.models.Group):
|
|||
class Team(models.Model):
|
||||
|
||||
class Meta:
|
||||
ordering = [ 'name' ]
|
||||
ordering = ['name']
|
||||
|
||||
name = models.CharField(max_length=128, unique=True)
|
||||
|
||||
|
|
|
@ -151,7 +151,8 @@ def group_add_user(request, group):
|
|||
else:
|
||||
user.groups.add(group)
|
||||
user.save()
|
||||
messages.success(request, 'User added to group successfully.')
|
||||
messages.success(request,
|
||||
'User added to group successfully.')
|
||||
else:
|
||||
messages.error(request, 'User not found.')
|
||||
return redirect('show-group', group.id)
|
||||
|
@ -160,12 +161,12 @@ def group_add_user(request, group):
|
|||
if not term:
|
||||
return Http404()
|
||||
query = Q(username__icontains=term) \
|
||||
| Q(first_name__icontains=term) \
|
||||
| Q(last_name__icontains=term)
|
||||
| Q(first_name__icontains=term) \
|
||||
| Q(last_name__icontains=term)
|
||||
users = User.objects.exclude(groups=group).filter(query)[:10]
|
||||
response = []
|
||||
for user in users:
|
||||
response += [ {
|
||||
response += [{
|
||||
'label': user.username_and_fullname,
|
||||
'value': user.username,
|
||||
}]
|
||||
|
@ -249,7 +250,8 @@ def team_add_user(request, team):
|
|||
else:
|
||||
team.users.add(user)
|
||||
team.save()
|
||||
messages.success(request, 'User added to team successfully.')
|
||||
messages.success(request,
|
||||
'User added to team successfully.')
|
||||
else:
|
||||
messages.error(request, 'User not found.')
|
||||
request.session['team-tab'] = 'user'
|
||||
|
@ -259,15 +261,15 @@ def team_add_user(request, team):
|
|||
if not term:
|
||||
return Http404()
|
||||
query = Q(username__icontains=term) \
|
||||
| Q(first_name__icontains=term) \
|
||||
| Q(last_name__icontains=term)
|
||||
| Q(first_name__icontains=term) \
|
||||
| Q(last_name__icontains=term)
|
||||
users = User.objects \
|
||||
.exclude(groups__in=team.groups.all()) \
|
||||
.exclude(id__in=team.users.values('id')) \
|
||||
.filter(query)[:10]
|
||||
.exclude(groups__in=team.groups.all()) \
|
||||
.exclude(id__in=team.users.values('id')) \
|
||||
.filter(query)[:10]
|
||||
response = []
|
||||
for user in users:
|
||||
response += [ {
|
||||
response += [{
|
||||
'label': user.username_and_fullname,
|
||||
'value': user.username,
|
||||
}]
|
||||
|
@ -299,7 +301,8 @@ def team_add_group(request, team):
|
|||
else:
|
||||
team.groups.add(group)
|
||||
team.save()
|
||||
messages.success(request, 'Group added to team successfully.')
|
||||
messages.success(request,
|
||||
'Group added to team successfully.')
|
||||
else:
|
||||
messages.error(request, 'Group not found.')
|
||||
request.session['team-tab'] = 'group'
|
||||
|
@ -309,11 +312,11 @@ def team_add_group(request, team):
|
|||
if not term:
|
||||
return Http404()
|
||||
groups = Group.objects \
|
||||
.exclude(id__in=team.groups.values('id')) \
|
||||
.filter(name__icontains=term)[:10]
|
||||
.exclude(id__in=team.groups.values('id')) \
|
||||
.filter(name__icontains=term)[:10]
|
||||
response = []
|
||||
for group in groups:
|
||||
response += [ {
|
||||
response += [{
|
||||
'label': group.name,
|
||||
'value': group.name,
|
||||
}]
|
||||
|
|
|
@ -7,7 +7,7 @@ from permissions.models import PermissionModel
|
|||
from accounts.models import *
|
||||
|
||||
|
||||
__all__ = [ 'GlobalPermissionForm', 'ProjectPermissionForm' ]
|
||||
__all__ = ['GlobalPermissionForm', 'ProjectPermissionForm']
|
||||
|
||||
|
||||
class PermissionForm(forms.ModelForm):
|
||||
|
@ -52,9 +52,9 @@ class GlobalPermissionForm(PermissionForm):
|
|||
|
||||
class Meta:
|
||||
model = GlobalPermission
|
||||
fields = [ 'grantee_type', 'grantee_id' ]
|
||||
fields = ['grantee_type', 'grantee_id']
|
||||
widgets = {
|
||||
'grantee_id': HiddenInput,
|
||||
'grantee_id': HiddenInput,
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ class ProjectPermissionForm(PermissionForm):
|
|||
class Meta:
|
||||
model = ProjectPermission
|
||||
# project is required for the unicity check
|
||||
fields = [ 'project', 'grantee_type', 'grantee_id' ]
|
||||
fields = ['project', 'grantee_type', 'grantee_id']
|
||||
widgets = {
|
||||
'project': HiddenInput,
|
||||
'grantee_id': HiddenInput,
|
||||
|
|
|
@ -7,7 +7,7 @@ from tracker.models import Project
|
|||
from accounts.models import *
|
||||
|
||||
|
||||
__all__ = [ 'GlobalPermission', 'ProjectPermission' ]
|
||||
__all__ = ['GlobalPermission', 'ProjectPermission']
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
|
@ -82,7 +82,7 @@ class PermissionModel(models.Model):
|
|||
class GlobalPermission(PermissionModel):
|
||||
|
||||
class Meta:
|
||||
unique_together = ( 'grantee_type', 'grantee_id' )
|
||||
unique_together = ('grantee_type', 'grantee_id')
|
||||
|
||||
# Global permissions
|
||||
|
||||
|
@ -120,7 +120,7 @@ class GlobalPermission(PermissionModel):
|
|||
class ProjectPermission(PermissionModel):
|
||||
|
||||
class Meta:
|
||||
unique_together = ( 'project', 'grantee_type', 'grantee_id' )
|
||||
unique_together = ('project', 'grantee_type', 'grantee_id')
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
|
||||
@receiver(pre_delete, sender=User, dispatch_uid="clean_user_perms")
|
||||
def clean_user_perms(sender, instance, **kwargs):
|
||||
# Clean global permissions
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
from ponytracker.settings import *
|
||||
|
||||
|
||||
### Uncomment to use celery worker
|
||||
### Don't forget to install a broker:
|
||||
### # http://docs.celeryproject.org/en/latest/getting-started/brokers/index.html#broker-overview
|
||||
#INSTALLED_APPS += ('djcelery',)
|
||||
#import djcelery
|
||||
#djcelery.setup_loader()
|
||||
# # Uncomment to use celery worker
|
||||
# # Don't forget to install a broker:
|
||||
# # http://docs.celeryproject.org/en/latest/getting-started/brokers/index.html#broker-overview
|
||||
# INSTALLED_APPS += ('djcelery',)
|
||||
# import djcelery
|
||||
# djcelery.setup_loader()
|
||||
|
||||
SECRET_KEY='CHANGE ME'
|
||||
SECRET_KEY = 'CHANGE ME'
|
||||
|
||||
DEBUG = False
|
||||
|
||||
|
|
|
@ -143,19 +143,22 @@ BOOTSTRAP3 = {
|
|||
#'base_url': '//netdna.bootstrapcdn.com/bootstrap/3.2.0/',
|
||||
'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,
|
||||
|
||||
# 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,
|
||||
|
||||
# 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,
|
||||
}
|
||||
|
||||
# Celery configuration
|
||||
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_TASK_SERIALIZER = 'json'
|
||||
CELERY_RESULT_SERIALIZER = 'json'
|
||||
|
|
4
tox.ini
4
tox.ini
|
@ -1,3 +1,3 @@
|
|||
[pep8]
|
||||
exclude=env,issue/migrations,issue/urls.py
|
||||
ignore=E128
|
||||
exclude=env,*/migrations,*/urls.py,doc
|
||||
ignore=E128,E265
|
||||
|
|
|
@ -16,7 +16,8 @@ class ProjectForm(forms.ModelForm):
|
|||
model = Project
|
||||
fields = ['display_name', 'name', 'description', 'access']
|
||||
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
|
||||
modules = [ 'accounts.views', 'permissions.views', 'tracker.views' ]
|
||||
modules = ['accounts.views', 'permissions.views', 'tracker.views']
|
||||
|
||||
|
||||
class ProjectMiddleware:
|
||||
|
|
|
@ -14,14 +14,14 @@ from accounts.models import User
|
|||
from tracker.templatetags.tracker_tags import *
|
||||
|
||||
|
||||
__all__ = [ 'Project', 'Issue', 'Label', 'Milestone', 'Event' ]
|
||||
__all__ = ['Project', 'Issue', 'Label', 'Milestone', 'Event']
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Project(models.Model):
|
||||
|
||||
class Meta:
|
||||
ordering = [ 'name' ]
|
||||
ordering = ['name']
|
||||
|
||||
ACCESS_PUBLIC = 1
|
||||
ACCESS_REGISTERED = 2
|
||||
|
@ -81,7 +81,7 @@ class Label(models.Model):
|
|||
class Milestone(models.Model):
|
||||
|
||||
class Meta:
|
||||
ordering = [ 'due_date' ]
|
||||
ordering = ['due_date']
|
||||
|
||||
name_validator = RegexValidator(regex='^[a-z0-9_.-]+$',
|
||||
message="Please enter only lowercase characters, number, "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue