Commit 05d26756 authored by Nate Case's avatar Nate Case Committed by Jeremy Kerr
Browse files

In some places tabs are used instead of spaces for indentation,


even when other lines of a method are indented with spaces.

This gets rid of all tabs and uses spaces everywhere.

[Reworked to apply on newer code by Jeremy]
Signed-off-by: default avatarNate Case <ncase@xes-inc.com>
Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
parent 04767c65
......@@ -2,7 +2,7 @@ from django.contrib import admin
from django.contrib.sites.models import Site
from django.contrib.auth.models import User
from patchwork.models import Project, Person, UserProfile, State, Patch, \
Comment, Bundle
Comment, Bundle
admin_site = admin.AdminSite()
......
......@@ -155,8 +155,8 @@ def find_content(project, mail):
if commentbuf:
if patch:
cpatch = patch
else:
cpatch = patch
else:
cpatch = find_patch_for_comment(mail)
if not cpatch:
return (None, None)
......
......@@ -79,7 +79,7 @@ class SubmitterFilter(Filter):
def __init__(self, filters):
super(SubmitterFilter, self).__init__(filters)
self.name = 'Submitter'
self.person = None
self.person = None
self.person_match = None
def _set_key(self, str):
......@@ -127,14 +127,14 @@ class SubmitterFilter(Filter):
return ''
def _form(self):
name = ''
if self.person:
name = self.person.name
return mark_safe(('<input onKeyUp="submitter_field_change(this)" ' +
'name="submitter" id="submitter_input" ' +
name = ''
if self.person:
name = self.person.name
return mark_safe(('<input onKeyUp="submitter_field_change(this)" ' +
'name="submitter" id="submitter_input" ' +
'value="%s">&nbsp;' % escape(name)) +
'<select id="submitter_select" ' +
'disabled="true"></select>')
'<select id="submitter_select" ' +
'disabled="true"></select>')
def key(self):
if self.person:
......@@ -146,7 +146,7 @@ class StateFilter(Filter):
def __init__(self, filters):
super(StateFilter, self).__init__(filters)
self.name = 'State'
self.state = None
self.state = None
def _set_key(self, str):
try:
......@@ -171,12 +171,12 @@ class StateFilter(Filter):
str = '<select name="%s">' % self.param
str += '<option value="">any</option>'
for state in State.objects.all():
selected = ''
selected = ''
if self.state and self.state == state:
selected = ' selected="true"'
selected = ' selected="true"'
str += '<option value="%d" %s>%s</option>' % \
(state.id, selected, state.name)
(state.id, selected, state.name)
str += '</select>'
return mark_safe(str);
......@@ -189,12 +189,12 @@ class SearchFilter(Filter):
super(SearchFilter, self).__init__(filters)
self.name = 'Search'
self.param = 'q'
self.search = None
self.search = None
def _set_key(self, str):
str = str.strip()
if str == '':
return
str = str.strip()
if str == '':
return
self.search = str
self.applied = True
......@@ -208,11 +208,11 @@ class SearchFilter(Filter):
return self.search
def _form(self):
value = ''
if self.search:
value = escape(self.search)
value = ''
if self.search:
value = escape(self.search)
return mark_safe('<input name="%s" value="%s">' %\
(self.param, value))
(self.param, value))
def form_function(self):
return mark_safe('function(form) { return form.x.value }')
......@@ -253,9 +253,9 @@ class ArchiveFilter(Filter):
return self.description_map[self.archive_state]
def key(self):
if self.archive_state == False:
return None
return self.param_map[self.archive_state]
if self.archive_state == False:
return None
return self.param_map[self.archive_state]
def _form(self):
s = ''
......@@ -402,7 +402,7 @@ class Filters:
def params(self):
return [ (f.param, f.key()) for f in self._filters \
if f.key() is not None ]
if f.key() is not None ]
def querystring(self, remove = None):
params = dict(self.params())
......
......@@ -77,7 +77,7 @@ class CreateBundleForm(forms.ModelForm):
class DelegateField(forms.ModelChoiceField):
def __init__(self, project, *args, **kwargs):
queryset = User.objects.filter(userprofile__in = \
queryset = User.objects.filter(userprofile__in = \
UserProfile.objects \
.filter(maintainer_projects = project) \
.values('pk').query)
......@@ -86,10 +86,10 @@ class DelegateField(forms.ModelChoiceField):
class PatchForm(forms.ModelForm):
def __init__(self, instance = None, project = None, *args, **kwargs):
if (not project) and instance:
if (not project) and instance:
project = instance.project
if not project:
raise Exception("meep")
raise Exception("meep")
super(PatchForm, self).__init__(instance = instance, *args, **kwargs)
self.fields['delegate'] = DelegateField(project, required = False)
......@@ -172,7 +172,7 @@ class MultiplePatchForm(PatchForm):
super(MultiplePatchForm, self).__init__(project = project,
*args, **kwargs)
self.fields['delegate'] = OptionalDelegateField(project = project,
required = False)
required = False)
def save(self, instance, commit = True):
opts = instance.__class__._meta
......
......@@ -79,8 +79,8 @@ class UserProfile(models.Model):
def name(self):
if self.user.first_name or self.user.last_name:
names = filter(bool, [self.user.first_name, self.user.last_name])
return ' '.join(names)
names = filter(bool, [self.user.first_name, self.user.last_name])
return ' '.join(names)
return self.user.username
def contributor_projects(self):
......@@ -114,16 +114,16 @@ class UserProfile(models.Model):
return qs
def save(self):
super(UserProfile, self).save()
people = Person.objects.filter(email = self.user.email)
if not people:
person = Person(email = self.user.email,
name = self.name(), user = self.user)
super(UserProfile, self).save()
people = Person.objects.filter(email = self.user.email)
if not people:
person = Person(email = self.user.email,
name = self.name(), user = self.user)
person.save()
else:
for person in people:
person.user = self.user
person.save()
else:
for person in people:
person.user = self.user
person.save()
def __str__(self):
return self.name()
......@@ -143,8 +143,8 @@ class UserPersonConfirmation(models.Model):
active = models.BooleanField(default = True)
def confirm(self):
if not self.active:
return
if not self.active:
return
person = None
try:
person = Person.objects.get(email = self.email)
......@@ -194,10 +194,10 @@ class HashField(models.Field):
n_bytes = len(hashlib.new(self.algorithm).digest())
else:
n_bytes = len(self.hash_constructor().digest())
if settings.DATABASE_ENGINE == 'postgresql':
return 'bytea'
elif settings.DATABASE_ENGINE == 'mysql':
return 'binary(%d)' % n_bytes
if settings.DATABASE_ENGINE == 'postgresql':
return 'bytea'
elif settings.DATABASE_ENGINE == 'mysql':
return 'binary(%d)' % n_bytes
def to_python(self, value):
return value
......@@ -226,10 +226,10 @@ class Patch(models.Model):
return self.name
def comments(self):
return Comment.objects.filter(patch = self)
return Comment.objects.filter(patch = self)
def save(self):
try:
try:
s = self.state
except:
self.state = State.objects.get(ordering = 0)
......
......@@ -170,8 +170,8 @@ def patch_hash(str):
if len(line) <= 0:
continue
hunk_match = _hunk_re.match(line)
filename_match = _filename_re.match(line)
hunk_match = _hunk_re.match(line)
filename_match = _filename_re.match(line)
if filename_match:
# normalise -p1 top-directories
......@@ -184,7 +184,7 @@ def patch_hash(str):
line = filename_match.group(1) + ' ' + filename
elif hunk_match:
elif hunk_match:
# remove line numbers
def fn(x):
if not x:
......
......@@ -28,9 +28,9 @@ register = template.Library()
@register.filter
def personify(person):
if person.name:
linktext = escape(person.name)
linktext = escape(person.name)
else:
linktext = escape(person.email)
linktext = escape(person.email)
return '<a href="javascript:personpopup(\'%s\')">%s</a>' % (escape(person.email), linktext)
......@@ -28,9 +28,9 @@ register = template.Library()
def personify(person):
if person.name:
linktext = escape(person.name)
linktext = escape(person.name)
else:
linktext = escape(person.email)
linktext = escape(person.email)
str = '<a href="mailto:%s">%s</a>' % \
(escape(person.email), linktext)
......
......@@ -36,9 +36,9 @@ urlpatterns = patterns('',
(r'^user/todo/(?P<project_id>[^/]+)/$', 'patchwork.views.user.todo_list'),
(r'^user/bundle/(?P<bundle_id>[^/]+)/$',
'patchwork.views.bundle.bundle'),
'patchwork.views.bundle.bundle'),
(r'^user/bundle/(?P<bundle_id>[^/]+)/mbox/$',
'patchwork.views.bundle.mbox'),
'patchwork.views.bundle.mbox'),
(r'^user/link/$', 'patchwork.views.user.link'),
(r'^user/link/(?P<key>[^/]+)/$', 'patchwork.views.user.link_confirm'),
......
......@@ -40,10 +40,10 @@ def get_patch_ids(d, prefix = 'patch_id'):
class Order(object):
order_map = {
'date': 'date',
'name': 'name',
'state': 'state__ordering',
'submitter': 'submitter__name'
'date': 'date',
'name': 'name',
'state': 'state__ordering',
'submitter': 'submitter__name'
}
default_order = 'date'
......
......@@ -55,12 +55,12 @@ def generic_list(request, project, view,
ps.append(patch)
(errors, form) = set_patches(request.user, project, action, \
request.POST, ps, context)
request.POST, ps, context)
if errors:
context['errors'] = errors
if not (request.user.is_authenticated() and \
project in request.user.get_profile().maintainer_projects.all()):
project in request.user.get_profile().maintainer_projects.all()):
form = None
for (filterclass, setting) in filter_settings:
......
......@@ -60,9 +60,9 @@ def submitter_complete(request):
search = request.GET.get('q', '')
response = HttpResponse(mimetype = "text/plain")
if len(search) > 3:
queryset = Person.objects.filter(name__icontains = search)
json_serializer = serializers.get_serializer("json")()
json_serializer.serialize(queryset, ensure_ascii=False, stream=response)
queryset = Person.objects.filter(name__icontains = search)
json_serializer = serializers.get_serializer("json")()
json_serializer.serialize(queryset, ensure_ascii=False, stream=response)
return response
help_pages = {'': 'index.html', 'about/': 'about.html'}
......
......@@ -25,7 +25,7 @@ from patchwork.utils import get_patch_ids, set_patches, Order
from patchwork.requestcontext import PatchworkRequestContext
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponse, HttpResponseRedirect, \
HttpResponseForbidden
HttpResponseForbidden
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.contrib.auth import authenticate, login
......@@ -71,7 +71,7 @@ def patch(request, patch_id):
bundle.save()
context.add_message('Patch added to bundle "%s"' % bundle.name)
# all other actions require edit privs
# all other actions require edit privs
elif not editable:
return HttpResponseForbidden()
......@@ -81,14 +81,14 @@ def patch(request, patch_id):
form.save()
context.add_message('Patch updated')
elif action == 'archive':
patch.archived = True
patch.save()
elif action == 'archive':
patch.archived = True
patch.save()
context.add_message('Patch archived')
elif action == 'unarchive':
patch.archived = False
patch.save()
elif action == 'unarchive':
patch.archived = False
patch.save()
context.add_message('Patch un-archived')
elif action == 'ack':
......@@ -157,13 +157,13 @@ def list(request, project_id):
ps.append(patch)
(errors, form) = set_patches(request.user, project, action, \
request.POST, ps)
request.POST, ps)
if errors:
context['errors'] = errors
elif request.user.is_authenticated() and \
project in request.user.get_profile().maintainer_projects.all():
project in request.user.get_profile().maintainer_projects.all():
form = MultiplePatchForm(project)
patches = Patch.objects.filter(project=project).order_by(order)
......
......@@ -24,9 +24,9 @@ from django.shortcuts import render_to_response, get_object_or_404
from django.contrib import auth
from django.http import HttpResponse, HttpResponseRedirect
from patchwork.models import Project, Patch, Bundle, Person, UserProfile, \
UserPersonConfirmation, State
UserPersonConfirmation, State
from patchwork.forms import MultiplePatchForm, UserProfileForm, \
UserPersonLinkForm
UserPersonLinkForm
from patchwork.utils import Order, get_patch_ids
from patchwork.filters import DelegateFilter
from patchwork.paginator import Paginator
......
......@@ -31,8 +31,8 @@ urlpatterns = patterns('',
# override the default registration form
url(r'^accounts/register/$',
register,
{'form_class': RegistrationForm,
'profile_callback': userprofile_register_callback},
{'form_class': RegistrationForm,
'profile_callback': userprofile_register_callback},
name='registration_register'),
(r'^accounts/', include('registration.urls')),
......@@ -41,9 +41,9 @@ urlpatterns = patterns('',
(r'^admin/(.*)', admin_site.root),
(r'^css/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '/srv/patchwork/htdocs/css'}),
{'document_root': '/srv/patchwork/htdocs/css'}),
(r'^js/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '/srv/patchwork/htdocs/js'}),
{'document_root': '/srv/patchwork/htdocs/js'}),
(r'^images/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '/srv/patchwork/htdocs/images'}),
{'document_root': '/srv/patchwork/htdocs/images'}),
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment