Fixed pep8 errors
This commit is contained in:
parent
4cc6539f0c
commit
3ffb16d4d8
@ -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
|
||||
|
@ -1,3 +1,2 @@
|
||||
import openslides.motion.signals
|
||||
import openslides.motion.slides
|
||||
|
||||
|
@ -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
|
||||
|
@ -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',
|
||||
|
@ -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)'))])
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user