From 3ffb16d4d843f0bfc9c44c0581f747393e6c35ad Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sat, 2 Feb 2013 10:52:13 +0100 Subject: [PATCH] Fixed pep8 errors --- .travis.yml | 2 +- openslides/motion/__init__.py | 1 - openslides/motion/models.py | 18 +++++++++--------- openslides/motion/views.py | 7 ++++--- openslides/motion/workflow.py | 28 ++++++++++++++-------------- openslides/utils/views.py | 5 +++-- 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f9a362aa..4772bb138 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,4 @@ install: - python extras/scripts/create_local_settings.py script: - 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 diff --git a/openslides/motion/__init__.py b/openslides/motion/__init__.py index 092f9eb05..e1cf60db8 100644 --- a/openslides/motion/__init__.py +++ b/openslides/motion/__init__.py @@ -1,3 +1,2 @@ import openslides.motion.signals import openslides.motion.slides - diff --git a/openslides/motion/models.py b/openslides/motion/models.py index 8e777e1ee..e1f0eb9a1 100644 --- a/openslides/motion/models.py +++ b/openslides/motion/models.py @@ -340,21 +340,21 @@ class Motion(SlideMixin, models.Model): * reset_state """ actions = { - 'edit': (self.is_submitter(person) and - self.state.edit_as_submitter) or - person.has_perm('motion.can_manage_motion'), + 'edit': ((self.is_submitter(person) and + self.state.edit_as_submitter) or + person.has_perm('motion.can_manage_motion')), - 'create_poll': person.has_perm('motion.can_manage_motion') and - self.state.create_poll, + 'create_poll': (person.has_perm('motion.can_manage_motion') and + self.state.create_poll), - 'support': self.state.support and - config['motion_min_supporters'] > 0 and - not self.is_submitter(person), + 'support': (self.state.support and + config['motion_min_supporters'] > 0 and + not self.is_submitter(person)), '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['reset_state'] = 'change_state' return actions diff --git a/openslides/motion/views.py b/openslides/motion/views.py index 3183d020d..74c9dd156 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -59,7 +59,7 @@ class MotionDetailView(DetailView): version_id = self.kwargs.get('version_id', None) if version_id is not None: try: - object.version = int(version_id) -1 + object.version = int(version_id) - 1 except IndexError: raise Http404 return object @@ -161,7 +161,7 @@ class SupportView(SingleObjectMixin, QuestionMixin, RedirectView): Checks whether request.user can support or unsupport the motion. Returns True or False. """ - return True #TODO + return True # TODO allowed_actions = self.object.get_allowed_actions(request.user) if self.support and not 'support' in allowed_actions: messages.error(request, _('You can not support this motion.')) @@ -267,7 +267,7 @@ class MotionSetStateView(SingleObjectMixin, RedirectView): self.object.state = kwargs['state'] except WorkflowError: messages.error(request, _('Can not set the state to: %s.') - % html_strong(kwargs['state'])) + % html_strong(kwargs['state'])) else: self.object.save() messages.success(request, _('Motion status was set to: %s.' @@ -338,6 +338,7 @@ def register_tab(request): selected=selected, ) + def get_widgets(request): return [Widget( name='motions', diff --git a/openslides/motion/workflow.py b/openslides/motion/workflow.py index d5533186a..51ddd65c2 100644 --- a/openslides/motion/workflow.py +++ b/openslides/motion/workflow.py @@ -7,19 +7,21 @@ ugettext = lambda s: s _workflow = None + class State(object): def __init__(self, id, name, next_states=[], create_poll=False, support=False, - edit_as_submitter=False): + edit_as_submitter=False): self.id = id self.name = name self.next_states = next_states self.create_poll = create_poll self.support = support - self.edit_as_submitter=edit_as_submitter + self.edit_as_submitter = edit_as_submitter def __unicode__(self): return self.name + class WorkflowError(Exception): pass @@ -73,15 +75,13 @@ def populate_workflow(state, workflow): DUMMY_STATE = State('dummy', ugettext('Unknwon state')) -default_workflow = State('pub', ugettext('Published'), support=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('rej', ugettext('Rejected')), - State('wit', ugettext('Withdrawed')), - State('adj', ugettext('Adjourned')), - State('noc', ugettext('Not Concerned')), - State('com', ugettext('Commited a bill')), - State('rev', ugettext('Needs Review'))]), - State('nop', ugettext('Rejected (not authorized)'))]) +default_workflow = State('pub', ugettext('Published'), support=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('rej', ugettext('Rejected')), + State('wit', ugettext('Withdrawed')), + State('adj', ugettext('Adjourned')), + State('noc', ugettext('Not Concerned')), + State('com', ugettext('Commited a bill')), + State('rev', ugettext('Needs Review'))]), + State('nop', ugettext('Rejected (not authorized)'))]) diff --git a/openslides/utils/views.py b/openslides/utils/views.py index 3f048f532..5d0428ec0 100644 --- a/openslides/utils/views.py +++ b/openslides/utils/views.py @@ -212,6 +212,7 @@ class TemplateView(PermissionMixin, ExtraContextMixin, _TemplateView): class ListView(PermissionMixin, SetCookieMixin, ExtraContextMixin, _ListView): pass + class AjaxView(PermissionMixin, AjaxMixin, View): def get(self, request, *args, **kwargs): return self.ajax_get(request, *args, **kwargs) @@ -270,7 +271,7 @@ class ModelFormMixin(object): class UpdateView(PermissionMixin, UrlMixin, ExtraContextMixin, - ModelFormMixin, _UpdateView): + ModelFormMixin, _UpdateView): def form_invalid(self, form): messages.error(self.request, _('Please check the form for errors.')) return super(UpdateView, self).form_invalid(form) @@ -280,7 +281,7 @@ class UpdateView(PermissionMixin, UrlMixin, ExtraContextMixin, class CreateView(PermissionMixin, UrlMixin, ExtraContextMixin, - ModelFormMixin, _CreateView): + ModelFormMixin, _CreateView): def form_invalid(self, form): messages.error(self.request, _('Please check the form for errors.')) return super(CreateView, self).form_invalid(form)