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.'))
@ -267,7 +267,7 @@ class MotionSetStateView(SingleObjectMixin, RedirectView):
self.object.state = kwargs['state'] self.object.state = kwargs['state']
except WorkflowError: except WorkflowError:
messages.error(request, _('Can not set the state to: %s.') messages.error(request, _('Can not set the state to: %s.')
% html_strong(kwargs['state'])) % html_strong(kwargs['state']))
else: else:
self.object.save() self.object.save()
messages.success(request, _('Motion status was set to: %s.' messages.success(request, _('Motion status was set to: %s.'
@ -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,19 +7,21 @@ 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):
self.id = id self.id = id
self.name = name self.name = name
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,15 +75,13 @@ 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, State('acc', ugettext('Accepted')),
edit_as_submitter=True, next_states=[ State('rej', ugettext('Rejected')),
State('acc', ugettext('Accepted')), State('wit', ugettext('Withdrawed')),
State('rej', ugettext('Rejected')), State('adj', ugettext('Adjourned')),
State('wit', ugettext('Withdrawed')), State('noc', ugettext('Not Concerned')),
State('adj', ugettext('Adjourned')), State('com', ugettext('Commited a bill')),
State('noc', ugettext('Not Concerned')), State('rev', ugettext('Needs Review'))]),
State('com', ugettext('Commited a bill')), State('nop', ugettext('Rejected (not authorized)'))])
State('rev', ugettext('Needs Review'))]),
State('nop', ugettext('Rejected (not authorized)'))])

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)
@ -270,7 +271,7 @@ class ModelFormMixin(object):
class UpdateView(PermissionMixin, UrlMixin, ExtraContextMixin, class UpdateView(PermissionMixin, UrlMixin, ExtraContextMixin,
ModelFormMixin, _UpdateView): ModelFormMixin, _UpdateView):
def form_invalid(self, form): def form_invalid(self, form):
messages.error(self.request, _('Please check the form for errors.')) messages.error(self.request, _('Please check the form for errors.'))
return super(UpdateView, self).form_invalid(form) return super(UpdateView, self).form_invalid(form)
@ -280,7 +281,7 @@ class UpdateView(PermissionMixin, UrlMixin, ExtraContextMixin,
class CreateView(PermissionMixin, UrlMixin, ExtraContextMixin, class CreateView(PermissionMixin, UrlMixin, ExtraContextMixin,
ModelFormMixin, _CreateView): ModelFormMixin, _CreateView):
def form_invalid(self, form): def form_invalid(self, form):
messages.error(self.request, _('Please check the form for errors.')) messages.error(self.request, _('Please check the form for errors.'))
return super(CreateView, self).form_invalid(form) return super(CreateView, self).form_invalid(form)