Fixed pep8 errors

This commit is contained in:
Oskar Hahn 2013-02-02 10:52:13 +01:00
parent 4cc6539f0c
commit 3ffb16d4d8
6 changed files with 31 additions and 30 deletions

View File

@ -8,4 +8,4 @@ install:
- python extras/scripts/create_local_settings.py - python extras/scripts/create_local_settings.py
script: script:
- coverage run ./manage.py test tests && coverage report -m - coverage run ./manage.py test tests && coverage report -m
- pep8 --max-line-length=150 --exclude="urls.py,motion/" --statistics openslides - pep8 --max-line-length=150 --exclude="urls.py," --statistics openslides

View File

@ -1,3 +1,2 @@
import openslides.motion.signals import openslides.motion.signals
import openslides.motion.slides import openslides.motion.slides

View File

@ -340,21 +340,21 @@ class Motion(SlideMixin, models.Model):
* reset_state * reset_state
""" """
actions = { actions = {
'edit': (self.is_submitter(person) and 'edit': ((self.is_submitter(person) and
self.state.edit_as_submitter) or self.state.edit_as_submitter) or
person.has_perm('motion.can_manage_motion'), person.has_perm('motion.can_manage_motion')),
'create_poll': person.has_perm('motion.can_manage_motion') and 'create_poll': (person.has_perm('motion.can_manage_motion') and
self.state.create_poll, self.state.create_poll),
'support': self.state.support and 'support': (self.state.support and
config['motion_min_supporters'] > 0 and config['motion_min_supporters'] > 0 and
not self.is_submitter(person), not self.is_submitter(person)),
'change_state': person.has_perm('motion.can_manage_motion'), 'change_state': person.has_perm('motion.can_manage_motion'),
} }
actions['delete'] = actions['edit'] #TODO: Only if the motion has no number actions['delete'] = actions['edit'] # TODO: Only if the motion has no number
actions['unsupport'] = actions['support'] actions['unsupport'] = actions['support']
actions['reset_state'] = 'change_state' actions['reset_state'] = 'change_state'
return actions return actions

View File

@ -59,7 +59,7 @@ class MotionDetailView(DetailView):
version_id = self.kwargs.get('version_id', None) version_id = self.kwargs.get('version_id', None)
if version_id is not None: if version_id is not None:
try: try:
object.version = int(version_id) -1 object.version = int(version_id) - 1
except IndexError: except IndexError:
raise Http404 raise Http404
return object return object
@ -161,7 +161,7 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView):
Checks whether request.user can support or unsupport the motion. Checks whether request.user can support or unsupport the motion.
Returns True or False. Returns True or False.
""" """
return True #TODO return True # TODO
allowed_actions = self.object.get_allowed_actions(request.user) allowed_actions = self.object.get_allowed_actions(request.user)
if self.support and not 'support' in allowed_actions: if self.support and not 'support' in allowed_actions:
messages.error(request, _('You can not support this motion.')) messages.error(request, _('You can not support this motion.'))
@ -338,6 +338,7 @@ def register_tab(request):
selected=selected, selected=selected,
) )
def get_widgets(request): def get_widgets(request):
return [Widget( return [Widget(
name='motions', name='motions',

View File

@ -7,6 +7,7 @@ ugettext = lambda s: s
_workflow = None _workflow = None
class State(object): class State(object):
def __init__(self, id, name, next_states=[], create_poll=False, support=False, def __init__(self, id, name, next_states=[], create_poll=False, support=False,
edit_as_submitter=False): edit_as_submitter=False):
@ -15,11 +16,12 @@ class State(object):
self.next_states = next_states self.next_states = next_states
self.create_poll = create_poll self.create_poll = create_poll
self.support = support self.support = support
self.edit_as_submitter=edit_as_submitter self.edit_as_submitter = edit_as_submitter
def __unicode__(self): def __unicode__(self):
return self.name return self.name
class WorkflowError(Exception): class WorkflowError(Exception):
pass pass
@ -73,10 +75,8 @@ def populate_workflow(state, workflow):
DUMMY_STATE = State('dummy', ugettext('Unknwon state')) DUMMY_STATE = State('dummy', ugettext('Unknwon state'))
default_workflow = State('pub', ugettext('Published'), support=True, default_workflow = State('pub', ugettext('Published'), support=True, edit_as_submitter=True, next_states=[
edit_as_submitter=True, next_states=[ State('per', ugettext('Permitted'), create_poll=True, edit_as_submitter=True, next_states=[
State('per', ugettext('Permitted'), create_poll=True,
edit_as_submitter=True, next_states=[
State('acc', ugettext('Accepted')), State('acc', ugettext('Accepted')),
State('rej', ugettext('Rejected')), State('rej', ugettext('Rejected')),
State('wit', ugettext('Withdrawed')), State('wit', ugettext('Withdrawed')),

View File

@ -212,6 +212,7 @@ class TemplateView(PermissionMixin, ExtraContextMixin, _TemplateView):
class ListView(PermissionMixin, SetCookieMixin, ExtraContextMixin, _ListView): class ListView(PermissionMixin, SetCookieMixin, ExtraContextMixin, _ListView):
pass pass
class AjaxView(PermissionMixin, AjaxMixin, View): class AjaxView(PermissionMixin, AjaxMixin, View):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
return self.ajax_get(request, *args, **kwargs) return self.ajax_get(request, *args, **kwargs)