diff --git a/fabfile.py b/fabfile.py index 0697345d6..5ab162176 100644 --- a/fabfile.py +++ b/fabfile.py @@ -45,12 +45,12 @@ def coverage(): webbrowser.open(os.path.join(os.path.dirname(__file__), 'htmlcov', 'index.html')) -def pep8(): +def check(): """ Checks for PEP 8 errors in openslides and in tests. """ - local('pep8 --max-line-length=150 --exclude="urls.py," --statistics openslides') - local('pep8 --max-line-length=150 --statistics tests') + local('flake8 --max-line-length=150 --statistics openslides') + local('flake8 --max-line-length=150 --statistics tests') def prepare_commit(): @@ -60,7 +60,7 @@ def prepare_commit(): At the moment it is running the tests and check for PEP 8 errors. """ test() - pep8() + check() def travis_ci(): @@ -68,7 +68,7 @@ def travis_ci(): Command that is run by Travis CI. """ coverage_report_plain() - pep8() + check() def run_script(script): diff --git a/openslides/account/views.py b/openslides/account/views.py index c8b9d2393..e2fc24dee 100644 --- a/openslides/account/views.py +++ b/openslides/account/views.py @@ -10,8 +10,8 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.utils.translation import ugettext as _ from django.contrib.auth.models import AnonymousUser +from django.utils.translation import ugettext as _ from openslides.config.api import config from openslides.projector.projector import Widget diff --git a/openslides/agenda/__init__.py b/openslides/agenda/__init__.py index 320161958..f9cc91d1c 100644 --- a/openslides/agenda/__init__.py +++ b/openslides/agenda/__init__.py @@ -12,4 +12,4 @@ :license: GNU GPL, see LICENSE for more details. """ -from . import signals, slides +from . import signals, slides # noqa diff --git a/openslides/agenda/forms.py b/openslides/agenda/forms.py index 5808eb441..947ec41b5 100644 --- a/openslides/agenda/forms.py +++ b/openslides/agenda/forms.py @@ -18,6 +18,7 @@ from mptt.forms import TreeNodeChoiceField from openslides.utils.forms import CssClassMixin from openslides.utils.person.forms import PersonFormField + from .models import Item, Speaker diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index fbd89fc0a..5c0b2858b 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -12,21 +12,20 @@ from datetime import datetime -from django.db import models from django.contrib.auth.models import AnonymousUser -from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic +from django.contrib.contenttypes.models import ContentType from django.core.urlresolvers import reverse -from django.utils.translation import ugettext_lazy, ugettext_noop, ugettext as _ - +from django.db import models +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy, ugettext_noop from mptt.models import MPTTModel, TreeForeignKey -from openslides.utils.exceptions import OpenSlidesError -from openslides.config.api import config -from openslides.utils.person.models import PersonField -from openslides.projector.api import ( - update_projector, get_active_slide, update_projector_overlay) +from openslides.projector.api import (get_active_slide, update_projector, + update_projector_overlay) from openslides.projector.models import SlideMixin +from openslides.utils.exceptions import OpenSlidesError +from openslides.utils.person.models import PersonField class Item(SlideMixin, MPTTModel): diff --git a/openslides/agenda/signals.py b/openslides/agenda/signals.py index e6bb8ea45..f046c10f8 100644 --- a/openslides/agenda/signals.py +++ b/openslides/agenda/signals.py @@ -12,22 +12,22 @@ from datetime import datetime +from django import forms from django.contrib.contenttypes.models import ContentType +from django.core.exceptions import ValidationError from django.db.models.signals import pre_delete from django.dispatch import receiver -from django import forms -from django.utils.translation import ugettext_lazy, ugettext_noop, ugettext as _ from django.template.loader import render_to_string -from django.core.exceptions import ValidationError +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy, ugettext_noop +from openslides.config.api import config, ConfigPage, ConfigVariable from openslides.config.signals import config_signal -from openslides.config.api import config, ConfigVariable, ConfigPage - -from openslides.projector.signals import projector_overlays -from openslides.projector.projector import Overlay from openslides.projector.api import get_active_slide +from openslides.projector.projector import Overlay +from openslides.projector.signals import projector_overlays -from .models import Speaker, Item +from .models import Item def validate_start_time(value): diff --git a/openslides/agenda/slides.py b/openslides/agenda/slides.py index 9d711789b..0a81298ed 100644 --- a/openslides/agenda/slides.py +++ b/openslides/agenda/slides.py @@ -13,7 +13,7 @@ from django.template.loader import render_to_string from openslides.config.api import config -from openslides.projector.api import register_slide, get_projector_content +from openslides.projector.api import get_projector_content, register_slide from .models import Item diff --git a/openslides/agenda/urls.py b/openslides/agenda/urls.py index a671a6685..e6d55c97c 100644 --- a/openslides/agenda/urls.py +++ b/openslides/agenda/urls.py @@ -10,114 +10,92 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.conf.urls import url, patterns -from openslides.agenda.views import ( - Overview, AgendaItemView, SetClosed, ItemUpdate, SpeakerSpeakView, SpeakerEndSpeachView, - ItemCreate, ItemDelete, AgendaPDF, SpeakerAppendView, SpeakerDeleteView, - SpeakerListCloseView, SpeakerChangeOrderView, CurrentListOfSpeakersView) +from django.conf.urls import patterns, url + +from . import views urlpatterns = patterns( '', url(r'^$', - Overview.as_view(), - name='item_overview', - ), + views.Overview.as_view(), + name='item_overview'), url(r'^(?P\d+)/$', - AgendaItemView.as_view(), - name='item_view', - ), + views.AgendaItemView.as_view(), + name='item_view'), url(r'^(?P\d+)/close/$', - SetClosed.as_view(), + views.SetClosed.as_view(), {'closed': True}, - name='item_close', - ), + name='item_close'), url(r'^(?P\d+)/open/$', - SetClosed.as_view(), + views.SetClosed.as_view(), {'closed': False}, - name='item_open', - ), + name='item_open'), url(r'^(?P\d+)/edit/$', - ItemUpdate.as_view(), - name='item_edit', - ), + views.ItemUpdate.as_view(), + name='item_edit'), url(r'^new/$', - ItemCreate.as_view(), - name='item_new', - ), + views.ItemCreate.as_view(), + name='item_new'), url(r'^(?P\d+)/del/$', - ItemDelete.as_view(), - name='item_delete', - ), + views.ItemDelete.as_view(), + name='item_delete'), url(r'^print/$', - AgendaPDF.as_view(), - name='print_agenda', - ), + views.AgendaPDF.as_view(), + name='print_agenda'), # List of speakers url(r'^(?P\d+)/speaker/$', - SpeakerAppendView.as_view(), - name='agenda_speaker_append', - ), + views.SpeakerAppendView.as_view(), + name='agenda_speaker_append'), url(r'^(?P\d+)/speaker/close/$', - SpeakerListCloseView.as_view(), - name='agenda_speaker_close', - ), + views.SpeakerListCloseView.as_view(), + name='agenda_speaker_close'), url(r'^(?P\d+)/speaker/reopen/$', - SpeakerListCloseView.as_view(reopen=True), - name='agenda_speaker_reopen', - ), + views.SpeakerListCloseView.as_view(reopen=True), + name='agenda_speaker_reopen'), url(r'^(?P\d+)/speaker/del/$', - SpeakerDeleteView.as_view(), - name='agenda_speaker_delete', - ), + views.SpeakerDeleteView.as_view(), + name='agenda_speaker_delete'), url(r'^(?P\d+)/speaker/(?P\d+)/del/$', - SpeakerDeleteView.as_view(), - name='agenda_speaker_delete', - ), + views.SpeakerDeleteView.as_view(), + name='agenda_speaker_delete'), url(r'^(?P\d+)/speaker/(?P[^/]+)/speak/$', - SpeakerSpeakView.as_view(), - name='agenda_speaker_speak', - ), + views.SpeakerSpeakView.as_view(), + name='agenda_speaker_speak'), url(r'^(?P\d+)/speaker/end_speach/$', - SpeakerEndSpeachView.as_view(), - name='agenda_speaker_end_speach', - ), + views.SpeakerEndSpeachView.as_view(), + name='agenda_speaker_end_speach'), url(r'^(?P\d+)/speaker/change_order/$', - SpeakerChangeOrderView.as_view(), - name='agenda_speaker_change_order', - ), + views.SpeakerChangeOrderView.as_view(), + name='agenda_speaker_change_order'), url(r'^list_of_speakers/$', - CurrentListOfSpeakersView.as_view(), - name='agenda_current_list_of_speakers', - ), + views.CurrentListOfSpeakersView.as_view(), + name='agenda_current_list_of_speakers'), url(r'^list_of_speakers/add/$', - CurrentListOfSpeakersView.as_view(set_speaker=True), - name='agenda_add_to_current_list_of_speakers', - ), + views.CurrentListOfSpeakersView.as_view(set_speaker=True), + name='agenda_add_to_current_list_of_speakers'), url(r'^list_of_speakers/next/$', - CurrentListOfSpeakersView.as_view(next_speaker=True), - name='agenda_next_on_current_list_of_speakers', - ), + views.CurrentListOfSpeakersView.as_view(next_speaker=True), + name='agenda_next_on_current_list_of_speakers'), url(r'^list_of_speakers/end_speach/$', - CurrentListOfSpeakersView.as_view(end_speach=True), - name='agenda_end_speach_on_current_list_of_speakers', - ) + views.CurrentListOfSpeakersView.as_view(end_speach=True), + name='agenda_end_speach_on_current_list_of_speakers') ) diff --git a/openslides/agenda/views.py b/openslides/agenda/views.py index c0a59c7c1..213154aad 100644 --- a/openslides/agenda/views.py +++ b/openslides/agenda/views.py @@ -11,28 +11,29 @@ """ # TODO: Rename all views and template names -from reportlab.platypus import Paragraph from datetime import datetime, timedelta -from django.core.urlresolvers import reverse from django.contrib import messages +from django.core.urlresolvers import reverse from django.db import transaction from django.db.models import Model -from django.utils.translation import ugettext as _, ugettext_lazy -from django.views.generic.detail import SingleObjectMixin +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy +from reportlab.platypus import Paragraph from openslides.config.api import config -from openslides.utils.pdf import stylesheet -from openslides.utils.exceptions import OpenSlidesError -from openslides.utils.views import ( - TemplateView, RedirectView, UpdateView, CreateView, DeleteView, PDFView, - DetailView, FormView, SingleObjectMixin) -from openslides.utils.template import Tab -from openslides.utils.utils import html_strong from openslides.projector.api import get_active_slide, update_projector from openslides.projector.projector import Widget +from openslides.utils.exceptions import OpenSlidesError +from openslides.utils.pdf import stylesheet +from openslides.utils.template import Tab +from openslides.utils.utils import html_strong +from openslides.utils.views import (CreateView, DeleteView, FormView, PDFView, + RedirectView, SingleObjectMixin, + TemplateView, UpdateView) + +from .forms import AppendSpeakerForm, ItemForm, ItemOrderForm, RelatedItemForm from .models import Item, Speaker -from .forms import ItemOrderForm, ItemForm, AppendSpeakerForm, RelatedItemForm class Overview(TemplateView): @@ -106,6 +107,7 @@ class Overview(TemplateView): messages.error( request, _('You are not authorized to manage the agenda.')) + context = self.get_context_data(**kwargs) return self.render_to_response(context) transaction.commit() diff --git a/openslides/assignment/__init__.py b/openslides/assignment/__init__.py index 29c22cb0b..ae4976120 100644 --- a/openslides/assignment/__init__.py +++ b/openslides/assignment/__init__.py @@ -10,5 +10,4 @@ :license: GNU GPL, see LICENSE for more details. """ -from . import signals -from . import slides +from . import signals, slides # noqa diff --git a/openslides/assignment/forms.py b/openslides/assignment/forms.py index b66a649a8..b8a37f054 100644 --- a/openslides/assignment/forms.py +++ b/openslides/assignment/forms.py @@ -16,7 +16,7 @@ from django.utils.translation import ugettext_lazy from openslides.utils.forms import CssClassMixin from openslides.utils.person import PersonFormField -from openslides.assignment.models import Assignment +from .models import Assignment class AssignmentForm(forms.ModelForm, CssClassMixin): diff --git a/openslides/assignment/models.py b/openslides/assignment/models.py index 5579e5ea8..0ffd64aef 100644 --- a/openslides/assignment/models.py +++ b/openslides/assignment/models.py @@ -12,15 +12,17 @@ from django.core.urlresolvers import reverse from django.db import models -from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop from django.utils.datastructures import SortedDict +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy, ugettext_noop +from openslides.config.api import config +from openslides.poll.models import (BaseOption, BasePoll, BaseVote, + CountInvalid, CountVotesCast, + PublishPollMixin) +from openslides.projector.models import RelatedModelMixin, SlideMixin from openslides.utils.person import PersonField from openslides.utils.utils import html_strong -from openslides.config.api import config -from openslides.projector.models import SlideMixin, RelatedModelMixin -from openslides.poll.models import ( - BasePoll, CountInvalid, CountVotesCast, BaseOption, PublishPollMixin, BaseVote) class AssignmentCandidate(RelatedModelMixin, models.Model): diff --git a/openslides/assignment/signals.py b/openslides/assignment/signals.py index e8a7c716e..1b8dc4326 100644 --- a/openslides/assignment/signals.py +++ b/openslides/assignment/signals.py @@ -10,12 +10,13 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.dispatch import receiver from django import forms -from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop +from django.dispatch import receiver +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy, ugettext_noop +from openslides.config.api import ConfigPage, ConfigVariable from openslides.config.signals import config_signal -from openslides.config.api import ConfigVariable, ConfigPage @receiver(config_signal, dispatch_uid='setup_assignment_config_page') diff --git a/openslides/assignment/slides.py b/openslides/assignment/slides.py index 744fac9f6..bd23c4660 100644 --- a/openslides/assignment/slides.py +++ b/openslides/assignment/slides.py @@ -11,7 +11,7 @@ """ from openslides.projector.api import register_slide_model + from .models import Assignment - register_slide_model(Assignment, 'assignment/slide.html') diff --git a/openslides/assignment/urls.py b/openslides/assignment/urls.py index 5fec7c4ce..3a3b7816b 100644 --- a/openslides/assignment/urls.py +++ b/openslides/assignment/urls.py @@ -10,111 +10,89 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.conf.urls import url, patterns +from django.conf.urls import patterns, url -from openslides.assignment.views import (AssignmentListView, AssignmentDetail, - AssignmentCreateView, AssignmentUpdateView, AssignmentDeleteView, - AssignmentSetStatusView, AssignmentRunView, AssignmentRunDeleteView, - AssignmentRunOtherDeleteView, PollCreateView, PollUpdateView, AssignmentPDF, - AssignmentPollPDF, AssignmentPollDeleteView, SetPublishStatusView, - SetElectedView, CreateRelatedAgendaItemView) +from . import views -urlpatterns = patterns('openslides.assignment.views', +urlpatterns = patterns( + '', url(r'^$', - AssignmentListView.as_view(), - name='assignment_list', - ), + views.AssignmentListView.as_view(), + name='assignment_list'), url(r'^(?P\d+)/$', - AssignmentDetail.as_view(), + views.AssignmentDetail.as_view(), name='assignment_detail'), url(r'^new/$', - AssignmentCreateView.as_view(), - name='assignment_create', - ), + views.AssignmentCreateView.as_view(), + name='assignment_create'), url(r'^(?P\d+)/edit/$', - AssignmentUpdateView.as_view(), - name='assignment_update', - ), + views.AssignmentUpdateView.as_view(), + name='assignment_update'), url(r'^(?P\d+)/del/$', - AssignmentDeleteView.as_view(), - name='assignment_delete', - ), + views.AssignmentDeleteView.as_view(), + name='assignment_delete'), url(r'^(?P\d+)/setstatus/(?P[a-z]{3})/$', - AssignmentSetStatusView.as_view(), - name='assignment_set_status', - ), + views.AssignmentSetStatusView.as_view(), + name='assignment_set_status'), url(r'^(?P\d+)/run/$', - AssignmentRunView.as_view(), - name='assignment_run', - ), + views.AssignmentRunView.as_view(), + name='assignment_run'), url(r'^(?P\d+)/delrun/$', - AssignmentRunDeleteView.as_view(), - name='assignment_delrun', - ), + views.AssignmentRunDeleteView.as_view(), + name='assignment_delrun'), url(r'^(?P\d+)/delother/(?P[^/]+)/$', - AssignmentRunOtherDeleteView.as_view(), - name='assignment_delother', - ), + views.AssignmentRunOtherDeleteView.as_view(), + name='assignment_delother'), url(r'^poll/(?P\d+)/print/$', - AssignmentPollPDF.as_view(), - name='assignment_poll_pdf', - ), + views.AssignmentPollPDF.as_view(), + name='assignment_poll_pdf'), url(r'^(?P\d+)/agenda/$', - CreateRelatedAgendaItemView.as_view(), - name='assignment_create_agenda', - ), + views.CreateRelatedAgendaItemView.as_view(), + name='assignment_create_agenda'), url(r'^print/$', - AssignmentPDF.as_view(), - name='assignment_list_pdf', - ), + views.AssignmentPDF.as_view(), + name='assignment_list_pdf'), url(r'^(?P\d+)/print/$', - AssignmentPDF.as_view(), - name='assignment_pdf', - ), + views.AssignmentPDF.as_view(), + name='assignment_pdf'), url(r'^(?P\d+)/gen_poll/$', - PollCreateView.as_view(), - name='assignment_poll_create', - ), + views.PollCreateView.as_view(), + name='assignment_poll_create'), url(r'^poll/(?P\d+)/$', - PollUpdateView.as_view(), - name='assignment_poll_view', - ), + views.PollUpdateView.as_view(), + name='assignment_poll_view'), url(r'^poll/(?P\d+)/del/$', - AssignmentPollDeleteView.as_view(), - name='assignment_poll_delete', - ), + views.AssignmentPollDeleteView.as_view(), + name='assignment_poll_delete'), # TODO: use seperate urls to publish and unpublish the poll # see assignment_user_elected url(r'^poll/(?P\d+)/pub/$', - SetPublishStatusView.as_view(), - name='assignment_poll_publish_status', - ), + views.SetPublishStatusView.as_view(), + name='assignment_poll_publish_status'), url(r'^(?P\d+)/elected/(?P[^/]+)/$', - SetElectedView.as_view(), + views.SetElectedView.as_view(), {'elected': True}, - name='assignment_user_elected', - ), + name='assignment_user_elected'), url(r'^(?P\d+)/notelected/(?P[^/]+)/$', - SetElectedView.as_view(), + views.SetElectedView.as_view(), {'elected': False}, - name='assignment_user_not_elected', - ), + name='assignment_user_not_elected') ) diff --git a/openslides/assignment/views.py b/openslides/assignment/views.py index c84e12a81..33d6228ad 100644 --- a/openslides/assignment/views.py +++ b/openslides/assignment/views.py @@ -12,32 +12,33 @@ import os -from reportlab.lib import colors -from reportlab.platypus import ( - SimpleDocTemplate, PageBreak, Paragraph, Spacer, Table, TableStyle) -from reportlab.lib.units import cm - from django.conf import settings -from django.core.urlresolvers import reverse from django.contrib import messages +from django.core.urlresolvers import reverse from django.shortcuts import redirect -from django.utils.translation import ungettext, ugettext as _ +from django.utils.translation import ugettext as _ +from django.utils.translation import ungettext +from reportlab.lib import colors +from reportlab.lib.units import cm +from reportlab.platypus import (PageBreak, Paragraph, SimpleDocTemplate, Spacer, + Table, TableStyle) -from openslides.utils.pdf import stylesheet -from openslides.utils.template import Tab - -from openslides.utils.views import ( - CreateView, DeleteView, RedirectView, UpdateView, ListView, PDFView, - DetailView, View, PermissionMixin, SingleObjectMixin, QuestionView) -from openslides.utils.person import get_person -from openslides.utils.utils import html_strong -from openslides.config.api import config -from openslides.participant.models import User, Group -from openslides.projector.projector import Widget -from openslides.poll.views import PollFormView from openslides.agenda.views import CreateRelatedAgendaItemView as _CreateRelatedAgendaItemView -from openslides.assignment.models import Assignment, AssignmentPoll -from openslides.assignment.forms import AssignmentForm, AssignmentRunForm +from openslides.config.api import config +from openslides.participant.models import Group, User +from openslides.poll.views import PollFormView +from openslides.projector.projector import Widget +from openslides.utils.pdf import stylesheet +from openslides.utils.person import get_person +from openslides.utils.template import Tab +from openslides.utils.utils import html_strong +from openslides.utils.views import (CreateView, DeleteView, DetailView, + ListView, PDFView, PermissionMixin, + QuestionView, RedirectView, + SingleObjectMixin, UpdateView, View) + +from .forms import AssignmentForm, AssignmentRunForm +from .models import Assignment, AssignmentPoll class AssignmentListView(ListView): diff --git a/openslides/config/api.py b/openslides/config/api.py index 9103d84a7..70c27723f 100644 --- a/openslides/config/api.py +++ b/openslides/config/api.py @@ -10,8 +10,8 @@ :license: GNU GPL, see LICENSE for more details. """ -from .models import ConfigStore from .exceptions import ConfigError, ConfigNotFound +from .models import ConfigStore from .signals import config_signal diff --git a/openslides/config/signals.py b/openslides/config/signals.py index 6fbe53c69..b7ee022dd 100644 --- a/openslides/config/signals.py +++ b/openslides/config/signals.py @@ -12,6 +12,5 @@ from django.dispatch import Signal - config_signal = Signal(providing_args=[]) """Signal to get all config tabs from all apps.""" diff --git a/openslides/config/urls.py b/openslides/config/urls.py index 6aa2d1265..c10cb5cd3 100644 --- a/openslides/config/urls.py +++ b/openslides/config/urls.py @@ -13,15 +13,15 @@ from django.conf.urls import patterns, url from openslides.utils.views import RedirectView + from .signals import config_signal from .views import ConfigView - -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^$', RedirectView.as_view(url_name='config_general'), - name='config_first_config_page', - ), + name='config_first_config_page') ) for receiver, config_page in config_signal.send(sender='config_urls'): diff --git a/openslides/config/views.py b/openslides/config/views.py index 1f140845f..4f2a6e5e2 100644 --- a/openslides/config/views.py +++ b/openslides/config/views.py @@ -11,12 +11,13 @@ """ from django import forms -from django.core.urlresolvers import reverse from django.contrib import messages -from django.utils.translation import ugettext as _, ugettext_lazy +from django.core.urlresolvers import reverse +from django.utils.translation import ugettext as _ -from openslides.utils.views import FormView from openslides.utils.template import Tab +from openslides.utils.views import FormView + from .api import config from .signals import config_signal diff --git a/openslides/core/__init__.py b/openslides/core/__init__.py index b31692336..84080af76 100644 --- a/openslides/core/__init__.py +++ b/openslides/core/__init__.py @@ -10,4 +10,4 @@ :license: GNU GPL, see LICENSE for more details. """ -from . import signals +from . import signals # noqa diff --git a/openslides/core/management/commands/backupdb.py b/openslides/core/management/commands/backupdb.py index f3a374ebe..f853184e5 100644 --- a/openslides/core/management/commands/backupdb.py +++ b/openslides/core/management/commands/backupdb.py @@ -4,7 +4,7 @@ from optparse import make_option import django.conf import django.db import django.db.transaction -from django.core.management.base import NoArgsCommand, CommandError +from django.core.management.base import CommandError, NoArgsCommand class Command(NoArgsCommand): diff --git a/openslides/core/signals.py b/openslides/core/signals.py index 158671218..bd0ac21b9 100644 --- a/openslides/core/signals.py +++ b/openslides/core/signals.py @@ -10,13 +10,13 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.dispatch import Signal, receiver from django import forms -from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop +from django.dispatch import receiver, Signal +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy, ugettext_noop +from openslides.config.api import ConfigGroup, ConfigGroupedPage, ConfigVariable from openslides.config.signals import config_signal -from openslides.config.api import ConfigVariable, ConfigGroup, ConfigGroupedPage - post_database_setup = Signal() diff --git a/openslides/core/templatetags/tags.py b/openslides/core/templatetags/tags.py index 6e1f342fa..391e585ff 100644 --- a/openslides/core/templatetags/tags.py +++ b/openslides/core/templatetags/tags.py @@ -14,18 +14,19 @@ import warnings from django import template from django.utils.translation import ugettext as _ -from openslides.config.api import config +from openslides.config.api import config register = template.Library() +# TODO: remove the tag get_config @register.simple_tag def get_config(key): return config[key] -@register.filter +@register.filter # noqa def get_config(key): return config[key] diff --git a/openslides/core/urls.py b/openslides/core/urls.py index 8059680ed..6d73466f7 100644 --- a/openslides/core/urls.py +++ b/openslides/core/urls.py @@ -13,17 +13,17 @@ from django.conf.urls import patterns, url from openslides.utils.views import RedirectView -from .views import VersionView +from . import views -urlpatterns = patterns('', - +urlpatterns = patterns( + '', # Redirect to dashboard URL url(r'^$', RedirectView.as_view(url='projector/dashboard/'), name='home',), url(r'^version/$', - VersionView.as_view(), + views.VersionView.as_view(), name='core_version',), ) diff --git a/openslides/core/views.py b/openslides/core/views.py index b33a91113..fd511d237 100644 --- a/openslides/core/views.py +++ b/openslides/core/views.py @@ -13,7 +13,7 @@ from django.conf import settings from django.utils.importlib import import_module -from openslides import get_version, get_git_commit_id, RELEASE +from openslides import get_git_commit_id, get_version, RELEASE from openslides.utils.views import TemplateView diff --git a/openslides/global_settings.py b/openslides/global_settings.py index 8de28da6b..9c2baea72 100644 --- a/openslides/global_settings.py +++ b/openslides/global_settings.py @@ -11,8 +11,6 @@ """ import os -import sys - from openslides.main import fs2unicode diff --git a/openslides/main.py b/openslides/main.py index a989b368c..fd7624eca 100644 --- a/openslides/main.py +++ b/openslides/main.py @@ -34,6 +34,7 @@ CONFIG_TEMPLATE = """#!/usr/bin/env python import openslides.main from openslides.global_settings import * + # Use 'DEBUG = True' to get more details for server errors # (Default for releases: 'False') DEBUG = False diff --git a/openslides/mediafile/urls.py b/openslides/mediafile/urls.py index 9cc1c0ff4..34fecb12f 100644 --- a/openslides/mediafile/urls.py +++ b/openslides/mediafile/urls.py @@ -10,31 +10,25 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.conf.urls import url, patterns +from django.conf.urls import patterns, url -from .models import Mediafile -from .views import (MediafileListView, MediafileCreateView, - MediafileUpdateView, MediafileDeleteView) +from . import views - -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^$', - MediafileListView.as_view(), - name='mediafile_list', - ), + views.MediafileListView.as_view(), + name='mediafile_list'), url(r'^new/$', - MediafileCreateView.as_view(), - name='mediafile_create', - ), + views.MediafileCreateView.as_view(), + name='mediafile_create'), url(r'^(?P\d+)/edit/$', - MediafileUpdateView.as_view(), - name='mediafile_update', - ), + views.MediafileUpdateView.as_view(), + name='mediafile_update'), url(r'^(?P\d+)/del/$', - MediafileDeleteView.as_view(), - name='mediafile_delete', - ), + views.MediafileDeleteView.as_view(), + name='mediafile_delete'), ) diff --git a/openslides/mediafile/views.py b/openslides/mediafile/views.py index 009d7cb62..af5838a60 100644 --- a/openslides/mediafile/views.py +++ b/openslides/mediafile/views.py @@ -14,10 +14,10 @@ from django.core.urlresolvers import reverse from django.utils.translation import ugettext as _ from openslides.utils.template import Tab -from openslides.utils.views import ListView, CreateView, UpdateView, DeleteView +from openslides.utils.views import CreateView, DeleteView, ListView, UpdateView -from .models import Mediafile from .forms import MediafileNormalUserCreateForm, MediafileUpdateForm +from .models import Mediafile class MediafileListView(ListView): diff --git a/openslides/motion/__init__.py b/openslides/motion/__init__.py index 6d62a31c2..451e97835 100644 --- a/openslides/motion/__init__.py +++ b/openslides/motion/__init__.py @@ -11,4 +11,4 @@ :license: GNU GPL, see LICENSE for more details. """ -from . import signals, slides +from . import signals, slides # noqa diff --git a/openslides/motion/csv_import.py b/openslides/motion/csv_import.py index 7c6ab4e71..694990ad7 100644 --- a/openslides/motion/csv_import.py +++ b/openslides/motion/csv_import.py @@ -17,13 +17,14 @@ import csv from django.db import transaction -from django.utils.translation import ugettext as _, ugettext_noop +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_noop from openslides.utils import csv_ext from openslides.utils.person.api import Persons from openslides.utils.utils import html_strong -from .models import Motion, Category +from .models import Category, Motion def import_motions(csv_file, default_submitter, override=False, importing_person=None): diff --git a/openslides/motion/exceptions.py b/openslides/motion/exceptions.py index 4dfdbd57f..21576068f 100644 --- a/openslides/motion/exceptions.py +++ b/openslides/motion/exceptions.py @@ -13,11 +13,6 @@ from openslides.utils.exceptions import OpenSlidesError -class MotionError(OpenSlidesError): - """Exception raised when errors in the motion accure.""" - pass - - class WorkflowError(OpenSlidesError): """Exception raised when errors in a workflow or state accure.""" pass diff --git a/openslides/motion/forms.py b/openslides/motion/forms.py index f738fa75c..80be63255 100644 --- a/openslides/motion/forms.py +++ b/openslides/motion/forms.py @@ -11,12 +11,14 @@ """ from django import forms -from django.utils.translation import ugettext as _, ugettext_lazy +from django.utils.translation import ugettext_lazy from openslides.config.api import config -from openslides.utils.forms import CssClassMixin, CleanHtmlFormMixin, LocalizedModelChoiceField -from openslides.utils.person import PersonFormField, MultiplePersonFormField -from .models import Motion, Category, Workflow +from openslides.utils.forms import (CleanHtmlFormMixin, CssClassMixin, + LocalizedModelChoiceField) +from openslides.utils.person import MultiplePersonFormField, PersonFormField + +from .models import Category, Motion, Workflow class BaseMotionForm(CleanHtmlFormMixin, CssClassMixin, forms.ModelForm): diff --git a/openslides/motion/models.py b/openslides/motion/models.py index 94c43c7d4..c0d9a01b4 100644 --- a/openslides/motion/models.py +++ b/openslides/motion/models.py @@ -13,27 +13,21 @@ :license: GNU GPL, see LICENSE for more details. """ -from datetime import datetime - from django.core.urlresolvers import reverse -from django.db import models, IntegrityError +from django.db import models from django.db.models import Max -from django.dispatch import receiver from django.utils import formats -from django.utils.translation import pgettext -from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy, ugettext_noop -from openslides.agenda.models import Item from openslides.config.api import config -from openslides.participant.models import User -from openslides.poll.models import ( - BaseOption, BasePoll, CountVotesCast, CountInvalid, BaseVote) -from openslides.projector.models import SlideMixin, RelatedModelMixin -from openslides.projector.api import (update_projector, get_active_slide) +from openslides.poll.models import (BaseOption, BasePoll, BaseVote, + CountInvalid, CountVotesCast) +from openslides.projector.models import RelatedModelMixin, SlideMixin from openslides.utils.jsonfield import JSONField from openslides.utils.person import PersonField -from .exceptions import MotionError, WorkflowError +from .exceptions import WorkflowError class Motion(SlideMixin, models.Model): diff --git a/openslides/motion/pdf.py b/openslides/motion/pdf.py index eb5deb725..2ef2fb341 100644 --- a/openslides/motion/pdf.py +++ b/openslides/motion/pdf.py @@ -10,24 +10,24 @@ :license: GNU GPL, see LICENSE for more details. """ -import random import os -from bs4 import BeautifulSoup +import random +from bs4 import BeautifulSoup +from django.conf import settings +from django.utils.translation import ugettext as _ from reportlab.lib import colors from reportlab.lib.units import cm -from reportlab.platypus import ( - SimpleDocTemplate, PageBreak, Paragraph, Spacer, Table, TableStyle) -from django.utils.translation import ugettext as _ -from django.conf import settings +from reportlab.platypus import PageBreak, Paragraph, Spacer, Table, TableStyle from openslides.config.api import config +from openslides.participant.models import Group, User from openslides.utils.pdf import stylesheet -from .models import Motion, Category + +from .models import Category, Motion # Needed to count the delegates # TODO: find another way to do this. -from openslides.participant.models import User, Group def motions_to_pdf(pdf): diff --git a/openslides/motion/signals.py b/openslides/motion/signals.py index b594b20ae..85648694f 100644 --- a/openslides/motion/signals.py +++ b/openslides/motion/signals.py @@ -10,15 +10,16 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.dispatch import receiver from django import forms -from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop +from django.dispatch import receiver +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy, ugettext_noop +from openslides.config.api import ConfigPage, ConfigVariable from openslides.config.signals import config_signal -from openslides.config.api import ConfigVariable, ConfigPage from openslides.core.signals import post_database_setup -from .models import Workflow, State +from .models import State, Workflow @receiver(config_signal, dispatch_uid='setup_motion_config_page') diff --git a/openslides/motion/slides.py b/openslides/motion/slides.py index 17ff5ca03..e4586f84a 100644 --- a/openslides/motion/slides.py +++ b/openslides/motion/slides.py @@ -11,6 +11,7 @@ """ from openslides.projector.api import register_slide_model + from .models import Motion register_slide_model(Motion, 'motion/slide.html') diff --git a/openslides/motion/urls.py b/openslides/motion/urls.py index b117dd7f6..8ed6a2956 100644 --- a/openslides/motion/urls.py +++ b/openslides/motion/urls.py @@ -10,133 +10,109 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.conf.urls import url, patterns +from django.conf.urls import patterns, url - -urlpatterns = patterns('openslides.motion.views', +# TODO: define the Views inhere +urlpatterns = patterns( + 'openslides.motion.views', url(r'^$', 'motion_list', - name='motion_list', - ), + name='motion_list'), url(r'^new/$', 'motion_create', # TODO: rename to motion_create - name='motion_new', - ), + name='motion_new'), url(r'^(?P\d+)/$', 'motion_detail', - name='motion_detail', - ), + name='motion_detail'), url(r'^(?P\d+)/edit/$', 'motion_update', - name='motion_update', - ), + name='motion_update'), url(r'^(?P\d+)/del/$', 'motion_delete', - name='motion_delete', - ), + name='motion_delete'), url(r'^(?P\d+)/version/(?P\d+)/$', 'motion_detail', - name='motion_version_detail', - ), + name='motion_version_detail'), url(r'^(?P\d+)/version/(?P\d+)/permit/$', 'version_permit', - name='motion_version_permit', - ), + name='motion_version_permit'), url(r'^(?P\d+)/version/(?P\d+)/del/$', 'version_delete', - name='motion_version_delete', - ), + name='motion_version_delete'), url(r'^(?P\d+)/diff/$', 'version_diff', - name='motion_version_diff', - ), + name='motion_version_diff'), url(r'^(?P\d+)/support/$', 'motion_support', - name='motion_support', - ), + name='motion_support'), url(r'^(?P\d+)/unsupport/$', 'motion_unsupport', - name='motion_unsupport', - ), + name='motion_unsupport'), url(r'^(?P\d+)/create_poll/$', 'poll_create', - name='motion_poll_create', - ), + name='motion_poll_create'), url(r'^(?P\d+)/poll/(?P\d+)/edit/$', 'poll_update', - name='motion_poll_update', - ), + name='motion_poll_update'), url(r'^(?P\d+)/poll/(?P\d+)/del/$', 'poll_delete', - name='motion_poll_delete', - ), + name='motion_poll_delete'), url(r'^(?P\d+)/poll/(?P\d+)/pdf/$', 'poll_pdf', - name='motion_poll_pdf', - ), + name='motion_poll_pdf'), url(r'^(?P\d+)/set_state/(?P\d+)/$', 'set_state', - name='motion_set_state', - ), + name='motion_set_state'), url(r'^(?P\d+)/reset_state/$', 'reset_state', - name='motion_reset_state', - ), + name='motion_reset_state'), url(r'^(?P\d+)/agenda/$', 'create_agenda_item', - name='motion_create_agenda', - ), + name='motion_create_agenda'), url(r'^pdf/$', 'motion_list_pdf', - name='motion_list_pdf', - ), + name='motion_list_pdf'), url(r'^(?P\d+)/pdf/$', 'motion_detail_pdf', - name='motion_detail_pdf', - ), + name='motion_detail_pdf'), url(r'^category/$', 'category_list', - name='motion_category_list', - ), + name='motion_category_list'), url(r'^category/new/$', 'category_create', - name='motion_category_create', - ), + name='motion_category_create'), url(r'^category/(?P\d+)/edit/$', 'category_update', - name='motion_category_update', - ), + name='motion_category_update'), url(r'^category/(?P\d+)/del/$', 'category_delete', - name='motion_category_delete', - ), + name='motion_category_delete'), url(r'^csv_import/$', 'motion_csv_import', - name='motion_csv_import', - ), + name='motion_csv_import'), ) diff --git a/openslides/motion/views.py b/openslides/motion/views.py index 5ba0a2381..d803fe53f 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -12,34 +12,33 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.core.urlresolvers import reverse from django.contrib import messages -from django.db import transaction -from django.db.models import Model +from django.core.urlresolvers import reverse from django.http import Http404, HttpResponseRedirect from django.utils.text import slugify -from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy, ugettext_noop from reportlab.platypus import SimpleDocTemplate -from openslides.utils.pdf import stylesheet -from openslides.utils.views import ( - TemplateView, RedirectView, UpdateView, CreateView, DeleteView, PDFView, - DetailView, ListView, FormView, QuestionView, SingleObjectMixin) +from openslides.agenda.views import CreateRelatedAgendaItemView as _CreateRelatedAgendaItemView +from openslides.config.api import config +from openslides.poll.views import PollFormView +from openslides.projector.api import get_active_slide, update_projector +from openslides.projector.projector import Widget from openslides.utils.template import Tab from openslides.utils.utils import html_strong, htmldiff -from openslides.poll.views import PollFormView -from openslides.projector.api import get_active_slide -from openslides.projector.projector import Widget -from openslides.config.api import config -from openslides.agenda.views import CreateRelatedAgendaItemView as _CreateRelatedAgendaItemView +from openslides.utils.views import (CreateView, DeleteView, DetailView, + FormView, ListView, PDFView, QuestionView, + RedirectView, SingleObjectMixin, UpdateView) from .csv_import import import_motions -from .models import (Motion, MotionSubmitter, MotionSupporter, MotionPoll, - MotionVersion, State, WorkflowError, Category) -from .forms import (BaseMotionForm, MotionSubmitterMixin, MotionSupporterMixin, - MotionDisableVersioningMixin, MotionCategoryMixin, - MotionIdentifierMixin, MotionWorkflowMixin, MotionImportForm) -from .pdf import motions_to_pdf, motion_to_pdf, motion_poll_to_pdf +from .forms import (BaseMotionForm, MotionCategoryMixin, + MotionDisableVersioningMixin, MotionIdentifierMixin, + MotionImportForm, MotionSubmitterMixin, + MotionSupporterMixin, MotionWorkflowMixin) +from .models import (Category, Motion, MotionPoll, MotionSubmitter, + MotionSupporter, MotionVersion, WorkflowError) +from .pdf import motion_poll_to_pdf, motion_to_pdf, motions_to_pdf class MotionListView(ListView): diff --git a/openslides/participant/__init__.py b/openslides/participant/__init__.py index d37cc3240..9a93f53fd 100644 --- a/openslides/participant/__init__.py +++ b/openslides/participant/__init__.py @@ -10,10 +10,4 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.utils.translation import ugettext_noop - -from . import signals -from . import slides - - -NAME = ugettext_noop('Participant') +from . import signals, slides # noqa diff --git a/openslides/participant/api.py b/openslides/participant/api.py index 621ae9b44..be9eb6771 100644 --- a/openslides/participant/api.py +++ b/openslides/participant/api.py @@ -10,15 +10,15 @@ :license: GNU GPL, see LICENSE for more details. """ -from random import choice import csv +from random import choice from django.db import transaction from django.utils.translation import ugettext as _ from openslides.utils import csv_ext -from openslides.participant.models import User, Group +from .models import Group, User def gen_password(): diff --git a/openslides/participant/forms.py b/openslides/participant/forms.py index a69326ef1..703206ec9 100644 --- a/openslides/participant/forms.py +++ b/openslides/participant/forms.py @@ -11,15 +11,16 @@ """ from django import forms -from django.contrib import messages -from django.contrib.auth.models import Permission -from django.utils.translation import ugettext as _, ugettext_lazy from django.conf import settings +from django.contrib.auth.models import Permission +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy -from openslides.utils.forms import CssClassMixin, LocalizedModelMultipleChoiceField -from openslides.participant.models import User, Group, get_protected_perm -from openslides.participant.api import get_registered_group from openslides.config.api import config +from openslides.utils.forms import (CssClassMixin, + LocalizedModelMultipleChoiceField) + +from .models import get_protected_perm, Group, User class UserCreateForm(CssClassMixin, forms.ModelForm): diff --git a/openslides/participant/models.py b/openslides/participant/models.py index 9da40bbc4..8c55fe243 100644 --- a/openslides/participant/models.py +++ b/openslides/participant/models.py @@ -10,18 +10,20 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.core.urlresolvers import reverse -from django.contrib.auth.models import User as DjangoUser, Group as DjangoGroup, Permission +from django.contrib.auth.models import Group as DjangoGroup +from django.contrib.auth.models import User as DjangoUser +from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType +from django.core.urlresolvers import reverse from django.db import models from django.db.models import signals from django.dispatch import receiver from django.utils.translation import ugettext_lazy, ugettext_noop -from openslides.utils.person import PersonMixin, Person -from openslides.utils.person.signals import receive_persons from openslides.config.api import config from openslides.projector.models import SlideMixin +from openslides.utils.person import Person, PersonMixin +from openslides.utils.person.signals import receive_persons class User(SlideMixin, PersonMixin, Person, DjangoUser): diff --git a/openslides/participant/signals.py b/openslides/participant/signals.py index 7e792d0b4..fbd3e1393 100644 --- a/openslides/participant/signals.py +++ b/openslides/participant/signals.py @@ -10,18 +10,19 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.dispatch import receiver from django import forms -from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop -from django.contrib.contenttypes.models import ContentType from django.contrib.auth.models import Permission +from django.contrib.contenttypes.models import ContentType +from django.dispatch import receiver +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy, ugettext_noop -from openslides.core.signals import post_database_setup +from openslides.config.api import ConfigPage, ConfigVariable from openslides.config.signals import config_signal -from openslides.config.api import ConfigVariable, ConfigPage +from openslides.core.signals import post_database_setup -from .models import Group from .api import create_or_reset_admin_user +from .models import Group @receiver(config_signal, dispatch_uid='setup_participant_config_page') diff --git a/openslides/participant/slides.py b/openslides/participant/slides.py index 62a529ff1..1843a0328 100644 --- a/openslides/participant/slides.py +++ b/openslides/participant/slides.py @@ -11,7 +11,8 @@ """ from openslides.projector.api import register_slide_model -from .models import User, Group + +from .models import Group, User register_slide_model(User, 'participant/user_slide.html') register_slide_model(Group, 'participant/group_slide.html') diff --git a/openslides/participant/urls.py b/openslides/participant/urls.py index 4e99df142..faa99816b 100644 --- a/openslides/participant/urls.py +++ b/openslides/participant/urls.py @@ -10,104 +10,83 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.conf.urls import url, patterns +from django.conf.urls import patterns, url -from openslides.participant.views import ( - UserOverview, UserCreateView, UserDetailView, UserUpdateView, - UserDeleteView, ResetPasswordView, SetUserStatusView, UserImportView, - GroupOverview, GroupCreateView, GroupDetailView, GroupUpdateView, GroupDeleteView, - ParticipantsListPDF, ParticipantsPasswordsPDF) - -urlpatterns = patterns('', +from . import views +urlpatterns = patterns( + '', # User url(r'^$', - UserOverview.as_view(), - name='user_overview', - ), + views.UserOverview.as_view(), + name='user_overview'), url(r'^new/$', - UserCreateView.as_view(), - name='user_new', - ), + views.UserCreateView.as_view(), + name='user_new'), url(r'^(?P\d+)/$', - UserDetailView.as_view(), - name='user_view', - ), + views.UserDetailView.as_view(), + name='user_view'), url(r'^(?P\d+)/edit/$', - UserUpdateView.as_view(), - name='user_edit', - ), + views.UserUpdateView.as_view(), + name='user_edit'), url(r'^(?P\d+)/del/$', - UserDeleteView.as_view(), - name='user_delete', - ), + views.UserDeleteView.as_view(), + name='user_delete'), url(r'^(?P\d+)/reset_password/$', - ResetPasswordView.as_view(), - name='user_reset_password', - ), + views.ResetPasswordView.as_view(), + name='user_reset_password'), url(r'^(?P\d+)/status/activate/$', - SetUserStatusView.as_view(), + views.SetUserStatusView.as_view(), {'action': 'activate'}, - name='user_status_activate', - ), + name='user_status_activate'), url(r'^(?P\d+)/status/deactivate/$', - SetUserStatusView.as_view(), + views.SetUserStatusView.as_view(), {'action': 'deactivate'}, - name='user_status_deactivate', - ), + name='user_status_deactivate'), url(r'^(?P\d+)/status/toggle/$', - SetUserStatusView.as_view(), + views.SetUserStatusView.as_view(), {'action': 'toggle'}, - name='user_status_toggle', - ), + name='user_status_toggle'), url(r'^import/$', - UserImportView.as_view(), - name='user_import', - ), + views.UserImportView.as_view(), + name='user_import'), # Group url(r'^group/$', - GroupOverview.as_view(), - name='user_group_overview', - ), + views.GroupOverview.as_view(), + name='user_group_overview'), url(r'^group/new/$', - GroupCreateView.as_view(), - name='user_group_new', - ), + views.GroupCreateView.as_view(), + name='user_group_new'), url(r'^group/(?P\d+)/$', - GroupDetailView.as_view(), - name='user_group_view', - ), + views.GroupDetailView.as_view(), + name='user_group_view'), url(r'^group/(?P\d+)/edit/$', - GroupUpdateView.as_view(), - name='user_group_edit', - ), + views.GroupUpdateView.as_view(), + name='user_group_edit'), url(r'^group/(?P\d+)/del/$', - GroupDeleteView.as_view(), - name='user_group_delete', - ), + views.GroupDeleteView.as_view(), + name='user_group_delete'), # PDF url(r'^print/$', - ParticipantsListPDF.as_view(), - name='user_print', - ), + views.ParticipantsListPDF.as_view(), + name='user_print'), url(r'^passwords/print/$', - ParticipantsPasswordsPDF.as_view(), - name='print_passwords', - ), + views.ParticipantsPasswordsPDF.as_view(), + name='print_passwords'), ) diff --git a/openslides/participant/views.py b/openslides/participant/views.py index 0396d9eea..f11431eb4 100644 --- a/openslides/participant/views.py +++ b/openslides/participant/views.py @@ -18,13 +18,6 @@ else: draw_qrcode = True from cStringIO import StringIO -from urllib import urlencode -from urlparse import parse_qs - -from reportlab.lib import colors -from reportlab.lib.units import cm -from reportlab.platypus import ( - SimpleDocTemplate, Paragraph, LongTable, Spacer, Table, TableStyle, Image) from django.contrib import messages from django.contrib.auth.decorators import login_required @@ -32,23 +25,28 @@ from django.contrib.auth.forms import PasswordChangeForm from django.contrib.auth.views import login as django_login from django.core.urlresolvers import reverse from django.shortcuts import redirect -from django.utils.translation import ugettext as _, ugettext_lazy, activate +from django.utils.translation import ugettext as _ +from django.utils.translation import activate, ugettext_lazy +from reportlab.lib import colors +from reportlab.lib.units import cm +from reportlab.platypus import (Image, LongTable, Paragraph, SimpleDocTemplate, + Spacer, Table, TableStyle) -from openslides.utils.pdf import stylesheet -from openslides.utils.template import Tab -from openslides.utils.utils import ( - template, delete_default_permissions, html_strong) -from openslides.utils.views import ( - FormView, PDFView, CreateView, UpdateView, DeleteView, PermissionMixin, - RedirectView, SingleObjectMixin, ListView, QuestionView, DetailView) from openslides.config.api import config from openslides.projector.projector import Widget +from openslides.utils.pdf import stylesheet +from openslides.utils.template import Tab +from openslides.utils.utils import (delete_default_permissions, html_strong, + template) +from openslides.utils.views import (CreateView, DeleteView, DetailView, + FormView, ListView, PDFView, + PermissionMixin, QuestionView, + RedirectView, SingleObjectMixin, UpdateView) -from .api import gen_username, gen_password, import_users -from .forms import ( - UserCreateForm, UserUpdateForm, UsersettingsForm, - UserImportForm, GroupForm) -from .models import User, Group, get_protected_perm +from .api import gen_password, gen_username, import_users +from .forms import (GroupForm, UserCreateForm, UserImportForm, UsersettingsForm, + UserUpdateForm) +from .models import get_protected_perm, Group, User class UserOverview(ListView): @@ -448,7 +446,7 @@ class GroupDeleteView(DeleteView): Checks whether the group is protected. """ if self.object.pk in [1, 2]: - messages.error(request, _('You can not delete this group.')) + messages.error(self.request, _('You can not delete this group.')) return True if (not self.request.user.is_superuser and get_protected_perm() in self.object.permissions.all() and diff --git a/openslides/poll/models.py b/openslides/poll/models.py index 986247d97..c6503a148 100644 --- a/openslides/poll/models.py +++ b/openslides/poll/models.py @@ -12,7 +12,8 @@ from django.core.exceptions import ObjectDoesNotExist from django.db import models -from django.utils.translation import ugettext_lazy as _, ugettext_noop +from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext_noop from openslides.utils.models import MinMaxIntegerField diff --git a/openslides/poll/views.py b/openslides/poll/views.py index 1571c10a2..5e22a7591 100644 --- a/openslides/poll/views.py +++ b/openslides/poll/views.py @@ -10,9 +10,9 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.http import HttpResponseRedirect -from django.forms.models import modelform_factory from django.core.exceptions import ImproperlyConfigured +from django.forms.models import modelform_factory +from django.http import HttpResponseRedirect from openslides.utils.views import TemplateView, FormMixin diff --git a/openslides/projector/__init__.py b/openslides/projector/__init__.py index 47bd8c0e5..f8fe5931f 100644 --- a/openslides/projector/__init__.py +++ b/openslides/projector/__init__.py @@ -10,4 +10,4 @@ :license: GNU GPL, see LICENSE for more details. """ -from . import signals, slides +from . import signals, slides # noqa diff --git a/openslides/projector/api.py b/openslides/projector/api.py index 91f07b593..fe34ea2a5 100644 --- a/openslides/projector/api.py +++ b/openslides/projector/api.py @@ -13,15 +13,14 @@ import json from django.conf import settings -from django.core.cache import cache +from django.template.loader import render_to_string from django.utils.datastructures import SortedDict from django.utils.importlib import import_module -from django.template.loader import render_to_string from openslides.config.api import config from openslides.utils.tornado_webserver import ProjectorSocketHandler -from .signals import projector_overlays +from .signals import projector_overlays slide_callback = {} """ @@ -48,7 +47,7 @@ def update_projector_overlay(overlay): ovleray or None. If it is None, all overlays will be updated. """ if overlay is None: - overlays = [overlay for overlay in get_overlays().values()] + overlays = [item for item in get_overlays().values()] elif isinstance(overlay, basestring): overlays = [get_overlays()[overlay]] else: @@ -115,13 +114,13 @@ def get_projector_overlays_js(): The retuned value is a list of json objects. """ - js = [] - for key, overlay in get_overlays().items(): + javascript = [] + for overlay in get_overlays().values(): if overlay.is_active(): overlay_js = overlay.get_javascript() if overlay_js: - js.append(json.dumps(overlay_js)) - return js + javascript.append(json.dumps(overlay_js)) + return javascript def register_slide(name, callback): @@ -158,13 +157,14 @@ def register_slide_model(SlideModel, template): register_slide(SlideModel.slide_callback_name, model_slide) -def set_active_slide(callback, kwargs={}): +def set_active_slide(callback, kwargs=None): """ Set the active Slide. callback: The name of the slide callback. kwargs: Keyword arguments for the slide callback. """ + kwargs = kwargs or {} kwargs.update(callback=callback) config['projector_active_slide'] = kwargs update_projector() diff --git a/openslides/projector/forms.py b/openslides/projector/forms.py index 59d69ef9c..44a70f088 100644 --- a/openslides/projector/forms.py +++ b/openslides/projector/forms.py @@ -15,7 +15,7 @@ from django import forms from openslides.utils.forms import CssClassMixin -class SelectWidgetsForm(forms.Form, CssClassMixin): +class SelectWidgetsForm(CssClassMixin, forms.Form): """ Form to select the widgets. """ diff --git a/openslides/projector/models.py b/openslides/projector/models.py index eafd4b9d9..3201d8052 100644 --- a/openslides/projector/models.py +++ b/openslides/projector/models.py @@ -10,11 +10,10 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.db import models -from django.dispatch import receiver -from django.utils.translation import ugettext_lazy, ugettext_noop from django.core.exceptions import ImproperlyConfigured from django.core.urlresolvers import reverse +from django.db import models +from django.utils.translation import ugettext_lazy, ugettext_noop from openslides.utils.utils import int_or_none @@ -64,7 +63,7 @@ class SlideMixin(object): def save(self, *args, **kwargs): """ - Updates the projector, if 'self' is the active slide. + Updates the projector, if the object is on the projector and changed. """ from openslides.projector.api import update_projector value = super(SlideMixin, self).save(*args, **kwargs) @@ -73,6 +72,9 @@ class SlideMixin(object): return value def delete(self, *args, **kwargs): + """ + Updates the projector, if the object is on the projector and is deleted. + """ from openslides.projector.api import update_projector value = super(SlideMixin, self).delete(*args, **kwargs) if self.is_active_slide(): @@ -100,9 +102,9 @@ class SlideMixin(object): """ from openslides.projector.api import get_active_slide active_slide = get_active_slide() - pk = int_or_none(active_slide.get('pk', None)) + slide_pk = int_or_none(active_slide.get('pk', None)) return (active_slide['callback'] == self.slide_callback_name and - self.pk == pk) + self.pk == slide_pk) def get_slide_context(self, **context): """ diff --git a/openslides/projector/projector.py b/openslides/projector/projector.py index 92daea2d0..f84c5ce8f 100644 --- a/openslides/projector/projector.py +++ b/openslides/projector/projector.py @@ -10,13 +10,10 @@ :license: GNU GPL, see LICENSE for more details. """ -from time import time - -from django.dispatch import receiver +from django.template import RequestContext from django.template.loader import render_to_string from openslides.config.api import config -from django.template import RequestContext from openslides.utils.exceptions import OpenSlidesError @@ -24,7 +21,7 @@ class Widget(object): """ Class for a Widget for the Projector-Tab. """ - def __init__(self, request, name, html=None, template=None, context={}, + def __init__(self, request, name, html=None, template=None, context=None, permission_required=None, display_name=None, default_column=1, default_weight=0): self.name = name @@ -38,7 +35,7 @@ class Widget(object): elif template is not None: self.html = render_to_string( template_name=template, - dictionary=context, + dictionary=context or {}, context_instance=RequestContext(request)) else: raise OpenSlidesError('A Widget must have either a html or a template argument.') @@ -47,12 +44,21 @@ class Widget(object): self.default_weight = default_weight def get_name(self): + """ + Returns the lower case of the widget name. + """ return self.name.lower() def get_html(self): + """ + Returns the html code of the widget. + """ return self.html def get_title(self): + """ + Returns the title of the widget. + """ return self.display_name def __repr__(self): @@ -76,15 +82,26 @@ class Overlay(object): self.allways_active = allways_active def get_widget_html(self): + """ + Returns the html code for the overlay widget. + + Can return None, if the widget does not want to be in the widget. + """ value = None if self.widget_html_callback is not None: value = self.widget_html_callback() return value def get_projector_html(self): + """ + Returns the html code for the projector. + """ return self.get_html_wrapper(self.projector_html_callback()) def get_javascript(self): + """ + Returns the java-script code for the projector. + """ if self.javascript_callback is None: value = {} else: @@ -92,12 +109,20 @@ class Overlay(object): return value def get_html_wrapper(self, inner_html): + """ + Returns the inner_html wrapped in a div. + + The html-id of the div is "overlay_OVERLAYNAME" + """ full_html = '' if inner_html is not None: full_html = '
%s
' % (self.name, inner_html) return full_html def is_active(self): + """ + Returns True if the overlay is activated. False in other case. + """ return self.allways_active or self.name in config['projector_active_overlays'] def set_active(self, active): @@ -115,4 +140,7 @@ class Overlay(object): config['projector_active_overlays'] = list(active_overlays) def show_on_projector(self): + """ + Retruns True if the overlay should be shoun on the projector. + """ return self.is_active() and self.get_projector_html() is not None diff --git a/openslides/projector/signals.py b/openslides/projector/signals.py index f93c17975..b683d4945 100644 --- a/openslides/projector/signals.py +++ b/openslides/projector/signals.py @@ -9,37 +9,31 @@ :copyright: 2011–2013 by OpenSlides team, see AUTHORS. :license: GNU GPL, see LICENSE for more details. """ -from time import time - -from django.dispatch import Signal, receiver -from django import forms -from django.template.loader import render_to_string -from django.core.context_processors import csrf from django.contrib.staticfiles.templatetags.staticfiles import static +from django.core.context_processors import csrf +from django.dispatch import receiver, Signal +from django.template.loader import render_to_string -from openslides.config.api import config, ConfigVariable, ConfigPage +from openslides.config.api import config, ConfigPage, ConfigVariable from openslides.config.signals import config_signal from .projector import Overlay - projector_overlays = Signal(providing_args=['request']) @receiver(config_signal, dispatch_uid='setup_projector_config_variables') -def setup_projector_config_variables(sender, **kwargs): +def config_variables(sender, **kwargs): """ Projector config variables for OpenSlides. They are not shown on a config page. """ + # The active slide. The config-value is a dictonary with at least the entry + # 'callback'. projector = ConfigVariable( name='projector_active_slide', default_value={'callback': None}) - """ - The active slide. The config-value is a dictonary with at least the entrie - 'callback'. - """ projector_message = ConfigVariable( name='projector_message', @@ -65,7 +59,7 @@ def setup_projector_config_variables(sender, **kwargs): name='bigger', default_value=100) - up = ConfigVariable( + projector_up = ConfigVariable( name='up', default_value=0) @@ -77,7 +71,7 @@ def setup_projector_config_variables(sender, **kwargs): title='No title here', url='bar', required_permission=None, variables=( projector, projector_message, countdown_time, countdown_start_stamp, countdown_pause_stamp, - countdown_state, bigger, up, projector_active_overlays)) + countdown_state, bigger, projector_up, projector_active_overlays)) @receiver(projector_overlays, dispatch_uid="projector_countdown") @@ -124,8 +118,8 @@ def countdown(sender, **kwargs): return Overlay(name, get_widget_html, get_projector_html, get_projector_js) -@receiver(projector_overlays, dispatch_uid="projector_message") -def projector_message(sender, **kwargs): +@receiver(projector_overlays, dispatch_uid="projector_overlay_message") +def projector_overlay_message(sender, **kwargs): """ Receiver to show the overlay_message on the projector or the form in the overlay-widget on the dashboard. diff --git a/openslides/projector/slides.py b/openslides/projector/slides.py index cb20e3b0e..a916abccd 100644 --- a/openslides/projector/slides.py +++ b/openslides/projector/slides.py @@ -14,5 +14,4 @@ from openslides.projector.api import register_slide_model from .models import ProjectorSlide - register_slide_model(ProjectorSlide, 'projector/slide_projectorslide.html') diff --git a/openslides/projector/urls.py b/openslides/projector/urls.py index c0f97ba4e..e8868f07a 100644 --- a/openslides/projector/urls.py +++ b/openslides/projector/urls.py @@ -12,127 +12,103 @@ from django.conf.urls import patterns, url -from openslides.projector.views import (DashboardView, ActivateView, - CustomSlideCreateView, CustomSlideUpdateView, CustomSlideDeleteView, - CountdownEdit, ProjectorEdit, Projector, ActivateOverlay, SelectWidgetsView, - OverlayMessageView) +from . import views - -urlpatterns = patterns('', +urlpatterns = patterns( + '', url(r'^$', - Projector.as_view(), - name='projector_show', - ), + views.Projector.as_view(), + name='projector_show'), url(r'^preview/$', - Projector.as_view(), + views.Projector.as_view(), {'callback': None}, - name='projctor_preview_welcomepage', - ), + name='projctor_preview_welcomepage'), url(r'^preview/(?P[^/]*)/$', - Projector.as_view(), - name='projector_preview', - ), + views.Projector.as_view(), + name='projector_preview'), url(r'^activate/(?P[^/]*)/$', - ActivateView.as_view(), - name='projector_activate_slide', - ), + views.ActivateView.as_view(), + name='projector_activate_slide'), url(r'^dashboard/$', - DashboardView.as_view(), - name='dashboard', - ), + views.DashboardView.as_view(), + name='dashboard'), url(r'^widgets/$', - SelectWidgetsView.as_view(), - name='projector_select_widgets', - ), + views.SelectWidgetsView.as_view(), + name='projector_select_widgets'), url(r'^overlay_message/$', - OverlayMessageView.as_view(), - name='projector_overlay_message', - ), + views.OverlayMessageView.as_view(), + name='projector_overlay_message'), url(r'^new/$', - CustomSlideCreateView.as_view(), - name='customslide_new', - ), + views.CustomSlideCreateView.as_view(), + name='customslide_new'), url(r'^(?P\d+)/edit/$', - CustomSlideUpdateView.as_view(), - name='customslide_edit', - ), + views.CustomSlideUpdateView.as_view(), + name='customslide_edit'), url(r'^(?P\d+)/del/$', - CustomSlideDeleteView.as_view(), - name='customslide_delete', - ), + views.CustomSlideDeleteView.as_view(), + name='customslide_delete'), url(r'^bigger/$', - ProjectorEdit.as_view(), + views.ProjectorEdit.as_view(), {'direction': 'bigger'}, - name='projector_bigger', - ), + name='projector_bigger'), url(r'^smaller/$', - ProjectorEdit.as_view(), + views.ProjectorEdit.as_view(), {'direction': 'smaller'}, - name='projector_smaller', - ), + name='projector_smaller'), url(r'^up/$', - ProjectorEdit.as_view(), + views.ProjectorEdit.as_view(), {'direction': 'up'}, - name='projector_up', - ), + name='projector_up'), url(r'^down/$', - ProjectorEdit.as_view(), + views.ProjectorEdit.as_view(), {'direction': 'down'}, - name='projector_down', - ), + name='projector_down'), url(r'^clean/$', - ProjectorEdit.as_view(), + views.ProjectorEdit.as_view(), {'direction': 'clean'}, - name='projector_clean', - ), + name='projector_clean'), url(r'^countdown/reset/$', - CountdownEdit.as_view(), - {'command': 'reset'}, - name='countdown_reset', - ), + views.CountdownEdit.as_view(), + {'command': 'reset'}, + name='countdown_reset'), url(r'^countdown/start/$', - CountdownEdit.as_view(), - {'command': 'start'}, - name='countdown_start', - ), + views.CountdownEdit.as_view(), + {'command': 'start'}, + name='countdown_start'), url(r'^countdown/stop/$', - CountdownEdit.as_view(), - {'command': 'stop'}, - name='countdown_stop', - ), + views.CountdownEdit.as_view(), + {'command': 'stop'}, + name='countdown_stop'), url(r'^countdown/set-default/$', - CountdownEdit.as_view(), - {'command': 'set-default'}, - name='countdown_set_default', - ), + views.CountdownEdit.as_view(), + {'command': 'set-default'}, + name='countdown_set_default'), url('^overlay/(?P[^/]*)/activate/$', - ActivateOverlay.as_view(), + views.ActivateOverlay.as_view(), {'activate': True}, - name='projector_overlay_activate', - ), + name='projector_overlay_activate'), url('^overlay/(?P[^/]*)/deactivate/$', - ActivateOverlay.as_view(), + views.ActivateOverlay.as_view(), {'activate': False}, - name='projector_overlay_deactivate', - ), + name='projector_overlay_deactivate'), ) diff --git a/openslides/projector/views.py b/openslides/projector/views.py index fd726ca65..14f3b47c4 100644 --- a/openslides/projector/views.py +++ b/openslides/projector/views.py @@ -10,27 +10,24 @@ :license: GNU GPL, see LICENSE for more details. """ -from datetime import datetime from time import time from django.contrib import messages -from django.core.cache import cache from django.core.context_processors import csrf from django.core.urlresolvers import reverse from django.db import transaction -from django.db.models import Q from django.shortcuts import redirect -from django.template import RequestContext from django.utils.translation import ugettext as _ -from openslides.utils.template import Tab -from openslides.utils.views import ( - TemplateView, RedirectView, CreateView, UpdateView, DeleteView, AjaxMixin) from openslides.config.api import config -from .api import ( - get_projector_content, get_projector_overlays, get_all_widgets, - set_active_slide, update_projector, get_active_slide, update_projector_overlay, - get_overlays, get_projector_overlays_js) +from openslides.utils.template import Tab +from openslides.utils.views import (AjaxMixin, CreateView, DeleteView, + RedirectView, TemplateView, UpdateView) + +from .api import (get_active_slide, get_all_widgets, get_overlays, + get_projector_content, get_projector_overlays, + get_projector_overlays_js, set_active_slide, + update_projector_overlay) from .forms import SelectWidgetsForm from .models import ProjectorSlide from .projector import Widget @@ -118,6 +115,9 @@ class SelectWidgetsView(TemplateView): @transaction.commit_manually def post(self, request, *args, **kwargs): + """ + Activates or deactivates the widgets in a post request. + """ context = self.get_context_data(**kwargs) activated_widgets = self.request.session.get('widgets', {}) diff --git a/openslides/urls.py b/openslides/urls.py index 3946ac8be..776d3c860 100644 --- a/openslides/urls.py +++ b/openslides/urls.py @@ -11,13 +11,13 @@ """ from django.conf import settings -from django.conf.urls import patterns, url, include +from django.conf.urls import include, patterns, url from django.utils.importlib import import_module - handler500 = 'openslides.utils.views.server_error' -urlpatterns = patterns('', +urlpatterns = patterns( + '', (r'^agenda/', include('openslides.agenda.urls')), (r'^motion/', include('openslides.motion.urls')), (r'^assignment/', include('openslides.assignment.urls')), @@ -28,7 +28,7 @@ urlpatterns = patterns('', (r'^i18n/', include('django.conf.urls.i18n')), ) -js_info_dict = {'packages': [],} +js_info_dict = {'packages': []} for plugin in settings.INSTALLED_PLUGINS: try: @@ -41,30 +41,29 @@ for plugin in settings.INSTALLED_PLUGINS: % plugin))) js_info_dict['packages'].append(plugin) -urlpatterns += patterns('', +# TODO: move this patterns into core or the participant app +urlpatterns += patterns( + '', (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), url(r'^login/$', 'openslides.participant.views.login', - name='user_login', - ), + name='user_login'), url(r'^logout/$', 'django.contrib.auth.views.logout_then_login', - name='user_logout', - ), + name='user_logout'), url(r'^usersettings/$', 'openslides.participant.views.user_settings', - name='user_settings', - ), + name='user_settings'), url(r'^usersettings/changepassword/$', 'openslides.participant.views.user_settings_password', - name='password_change', - ), + name='password_change'), ) -urlpatterns += patterns('', +urlpatterns += patterns( + '', (r'^', include('openslides.core.urls')), ) diff --git a/openslides/utils/auth/AnonymousAuth.py b/openslides/utils/auth/AnonymousAuth.py index da5a6dbfd..bd34482c9 100644 --- a/openslides/utils/auth/AnonymousAuth.py +++ b/openslides/utils/auth/AnonymousAuth.py @@ -11,6 +11,7 @@ """ from django.contrib.auth.models import Permission + from openslides.config.api import config diff --git a/openslides/utils/auth/__init__.py b/openslides/utils/auth/__init__.py index 202ca0203..8107c7fe4 100644 --- a/openslides/utils/auth/__init__.py +++ b/openslides/utils/auth/__init__.py @@ -5,4 +5,4 @@ :license: GNU GPL, see LICENSE for more details. """ -from AnonymousAuth import * +from AnonymousAuth import * # noqa diff --git a/openslides/utils/forms.py b/openslides/utils/forms.py index ebc16d492..786dc0fd0 100644 --- a/openslides/utils/forms.py +++ b/openslides/utils/forms.py @@ -11,10 +11,9 @@ """ import bleach - from django import forms -from django.utils.translation import ugettext as _, ugettext_lazy - +from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy # Allowed tags, attributes and styles allowed in textareas edited with a JS # editor. Everything not in these whitelists is stripped. diff --git a/openslides/utils/jsonfield/fields.py b/openslides/utils/jsonfield/fields.py index 4b31553f3..2a4e6cf3b 100644 --- a/openslides/utils/jsonfield/fields.py +++ b/openslides/utils/jsonfield/fields.py @@ -1,10 +1,10 @@ import json -from django.db import models from django.core.serializers.json import DjangoJSONEncoder -from django.utils.translation import ugettext as _ +from django.db import models from django.forms.fields import Field from django.forms.util import ValidationError as FormValidationError +from django.utils.translation import ugettext as _ class JSONFormField(Field): diff --git a/openslides/utils/pdf.py b/openslides/utils/pdf.py index bf0934eab..cab81057c 100644 --- a/openslides/utils/pdf.py +++ b/openslides/utils/pdf.py @@ -13,20 +13,18 @@ from datetime import datetime from os.path import join as path_join +from django.conf import settings +from django.utils import formats +from django.utils.translation import ugettext as _ from reportlab.lib import colors -from reportlab.lib.styles import StyleSheet1, ParagraphStyle +from reportlab.lib.styles import ParagraphStyle, StyleSheet1 from reportlab.lib.units import cm from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttfonts import TTFont from reportlab.rl_config import defaultPageSize -from django.conf import settings -from django.utils import formats -from django.utils.translation import ugettext as _ - from openslides.config.api import config - # register new truetype fonts pdfmetrics.registerFont(TTFont( 'Ubuntu', path_join(settings.SITE_ROOT, 'static/fonts/Ubuntu-R.ttf'))) diff --git a/openslides/utils/person/forms.py b/openslides/utils/person/forms.py index df046b00b..540c3e01a 100644 --- a/openslides/utils/person/forms.py +++ b/openslides/utils/person/forms.py @@ -12,7 +12,7 @@ from django import forms -from openslides.utils.person.api import Persons, get_person +from openslides.utils.person.api import get_person, Persons class PersonChoices(object): diff --git a/openslides/utils/person/models.py b/openslides/utils/person/models.py index bf271d890..fc81b31e9 100644 --- a/openslides/utils/person/models.py +++ b/openslides/utils/person/models.py @@ -9,13 +9,13 @@ :copyright: 2011, 2012 by OpenSlides team, see AUTHORS. :license: GNU GPL, see LICENSE for more details. """ -from django.db import models from django.contrib.auth.models import AnonymousUser +from django.db import models from openslides.utils.exceptions import OpenSlidesError +from .api import generate_person_id, get_person from .forms import PersonFormField -from .api import get_person, generate_person_id class PersonField(models.fields.Field): diff --git a/openslides/utils/test.py b/openslides/utils/test.py index 83187df94..ce6438a83 100644 --- a/openslides/utils/test.py +++ b/openslides/utils/test.py @@ -13,8 +13,8 @@ from django.test import TestCase as _TestCase -from openslides.core.signals import post_database_setup from openslides.config.api import config +from openslides.core.signals import post_database_setup class TestCase(_TestCase): diff --git a/openslides/utils/tornado_webserver.py b/openslides/utils/tornado_webserver.py index a6a7219c6..b3bc3b305 100644 --- a/openslides/utils/tornado_webserver.py +++ b/openslides/utils/tornado_webserver.py @@ -11,16 +11,15 @@ import posixpath from urllib import unquote +from django.conf import settings +from django.core.handlers.wsgi import WSGIHandler as Django_WSGIHandler +from django.utils.translation import ugettext as _ from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop -from tornado.web import FallbackHandler, Application, StaticFileHandler +from tornado.options import parse_command_line +from tornado.web import Application, FallbackHandler, StaticFileHandler from tornado.websocket import WebSocketHandler from tornado.wsgi import WSGIContainer -from tornado.options import parse_command_line - -from django.core.handlers.wsgi import WSGIHandler as Django_WSGIHandler -from django.conf import settings -from django.utils.translation import ugettext as _ class DjangoStaticFileHandler(StaticFileHandler): diff --git a/openslides/utils/views.py b/openslides/utils/views.py index 9ab1b4be7..6cd3d9485 100644 --- a/openslides/utils/views.py +++ b/openslides/utils/views.py @@ -12,8 +12,6 @@ import json from cStringIO import StringIO -from reportlab.platypus import SimpleDocTemplate, Spacer -from reportlab.lib.units import cm from django.conf import settings from django.contrib import messages @@ -32,7 +30,6 @@ from django.utils.translation import ugettext as _ from django.utils.translation import ugettext_lazy from django.views import generic as django_views from django.views.generic.detail import SingleObjectMixin -from django.views.generic.list import TemplateResponseMixin from reportlab.lib.units import cm from reportlab.platypus import SimpleDocTemplate, Spacer diff --git a/requirements.txt b/requirements.txt index b8898ccd9..3c7838017 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ Fabric==1.6.1 coverage==3.6 django-discover-runner==0.4 -pep8==1.4.5 +flake8==2.0 # Requirements for OpenSlides handbook/documentation Sphinx==1.2b1 diff --git a/tests/account/test_widgets.py b/tests/account/test_widgets.py index 4a603ff74..ab9170460 100644 --- a/tests/account/test_widgets.py +++ b/tests/account/test_widgets.py @@ -10,9 +10,9 @@ from django.test.client import Client -from openslides.utils.test import TestCase from openslides.config.api import config from openslides.participant.models import User +from openslides.utils.test import TestCase class PersonalInfoWidget(TestCase): @@ -79,8 +79,8 @@ class PersonalInfoWidget(TestCase): if motion: motion_1 = motion.models.Motion.objects.create(title='My Motion Title pa8aeNohYai0ahge', text='My Motion Text') motion_2 = motion.models.Motion.objects.create(title='My Motion Title quielohL7vah1weochai', text='My Motion Text') - submitter_1 = motion.models.MotionSubmitter.objects.create(motion=motion_1, person=self.user) - submitter_2 = motion.models.MotionSubmitter.objects.create(motion=motion_2, person=self.user) + motion.models.MotionSubmitter.objects.create(motion=motion_1, person=self.user) + motion.models.MotionSubmitter.objects.create(motion=motion_2, person=self.user) response = self.client.get('/projector/dashboard/') self.assertContains(response, 'I submitted the following motions:', status_code=200) self.assertContains(response, 'My Motion Title pa8aeNohYai0ahge', status_code=200) @@ -91,8 +91,8 @@ class PersonalInfoWidget(TestCase): if motion: motion_1 = motion.models.Motion.objects.create(title='My Motion Title jahN9phaiThae5ooKubu', text='My Motion Text') motion_2 = motion.models.Motion.objects.create(title='My Motion Title vech9ash8aeh9eej2Ga2', text='My Motion Text') - supporter_1 = motion.models.MotionSupporter.objects.create(motion=motion_1, person=self.user) - supporter_2 = motion.models.MotionSupporter.objects.create(motion=motion_2, person=self.user) + motion.models.MotionSupporter.objects.create(motion=motion_1, person=self.user) + motion.models.MotionSupporter.objects.create(motion=motion_2, person=self.user) config['motion_min_supporters'] = 1 response = self.client.get('/projector/dashboard/') self.assertContains(response, 'I support the following motions:', status_code=200) diff --git a/tests/agenda/test_list_of_speakers.py b/tests/agenda/test_list_of_speakers.py index b80d9a065..74516f756 100644 --- a/tests/agenda/test_list_of_speakers.py +++ b/tests/agenda/test_list_of_speakers.py @@ -9,12 +9,11 @@ from django.test.client import Client +from openslides.agenda.models import Item, Speaker +from openslides.participant.models import Group, User +from openslides.projector.api import set_active_slide from openslides.utils.exceptions import OpenSlidesError from openslides.utils.test import TestCase -from openslides.participant.models import User, Group -from openslides.agenda.models import Item, Speaker -from openslides.config.api import config -from openslides.projector.api import set_active_slide class ListOfSpeakerModelTests(TestCase): @@ -151,7 +150,7 @@ class TestAgendaItemView(SpeakerViewTestCase): group = Group.objects.create(name='test', group_as_person=True) Speaker.objects.add(group, self.item1) self.assertTrue(Speaker.objects.filter(person=group.person_id, item=self.item1).exists()) - response = self.admin_client.get('/agenda/1/') + self.admin_client.get('/agenda/1/') class TestSpeakerDeleteView(SpeakerViewTestCase): @@ -167,7 +166,7 @@ class TestSpeakerDeleteView(SpeakerViewTestCase): self.assertFalse(Speaker.objects.filter(person=self.speaker1, item=self.item1).exists()) def test_post_as_user(self): - speaker = Speaker.objects.add(self.speaker1, self.item1) + Speaker.objects.add(self.speaker1, self.item1) response = self.speaker1_client.post( '/agenda/1/speaker/del/', {'yes': 'yes'}) @@ -204,11 +203,11 @@ class TestSpeakerEndSpeachView(SpeakerViewTestCase): class SpeakerListOpenView(SpeakerViewTestCase): def test_get(self): - response = self.check_url('/agenda/1/speaker/close/', self.admin_client, 302) + self.check_url('/agenda/1/speaker/close/', self.admin_client, 302) item = Item.objects.get(pk=self.item1.pk) self.assertTrue(item.speaker_list_closed) - response = self.check_url('/agenda/1/speaker/reopen/', self.admin_client, 302) + self.check_url('/agenda/1/speaker/reopen/', self.admin_client, 302) item = Item.objects.get(pk=self.item1.pk) self.assertFalse(item.speaker_list_closed) diff --git a/tests/agenda/tests.py b/tests/agenda/tests.py index 3b08da8ba..d8a93c6ad 100644 --- a/tests/agenda/tests.py +++ b/tests/agenda/tests.py @@ -10,16 +10,14 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.test.client import Client from django.db.models.query import EmptyQuerySet +from django.test.client import Client -from openslides.utils.test import TestCase -from openslides.projector.api import get_active_slide, set_active_slide -from openslides.participant.models import User from openslides.agenda.models import Item -from openslides.agenda.slides import agenda_slide +from openslides.participant.models import User +from openslides.utils.test import TestCase -from .models import RelatedItem, BadRelatedItem +from .models import BadRelatedItem, RelatedItem class ItemTest(TestCase): diff --git a/tests/assignment/test_models.py b/tests/assignment/test_models.py index ce58931f2..2f76a64b0 100644 --- a/tests/assignment/test_models.py +++ b/tests/assignment/test_models.py @@ -10,10 +10,10 @@ from django.test.client import Client -from openslides.utils.test import TestCase from openslides.agenda.models import Item from openslides.assignment.models import Assignment from openslides.participant.models import User +from openslides.utils.test import TestCase class AssignmentModelTest(TestCase): diff --git a/tests/assignment/test_views.py b/tests/assignment/test_views.py index 7d3285ea5..f02567219 100644 --- a/tests/assignment/test_views.py +++ b/tests/assignment/test_views.py @@ -10,10 +10,9 @@ from django.test.client import Client -from openslides.config.api import config -from openslides.utils.test import TestCase from openslides.assignment.models import Assignment -from openslides.participant.models import User, Group +from openslides.participant.models import Group, User +from openslides.utils.test import TestCase class AssignmentViewTestCase(TestCase): diff --git a/tests/config/test_config.py b/tests/config/test_config.py index 04fa38da2..808e96875 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -8,17 +8,18 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.test.client import Client -from django.dispatch import receiver -from django.contrib.contenttypes.models import ContentType -from django.contrib.auth.models import Permission from django import forms +from django.contrib.auth.models import Permission +from django.contrib.contenttypes.models import ContentType +from django.dispatch import receiver +from django.test.client import Client -from openslides.utils.test import TestCase -from openslides.participant.models import User -from openslides.config.api import config, ConfigGroupedPage, ConfigPage, ConfigGroup, ConfigVariable -from openslides.config.signals import config_signal +from openslides.config.api import (config, ConfigGroup, ConfigGroupedPage, + ConfigPage, ConfigVariable) from openslides.config.exceptions import ConfigError, ConfigNotFound +from openslides.config.signals import config_signal +from openslides.participant.models import User +from openslides.utils.test import TestCase class HandleConfigTest(TestCase): diff --git a/tests/core/test_template_tags_filters.py b/tests/core/test_template_tags_filters.py index 1a41624a1..46fa931fc 100644 --- a/tests/core/test_template_tags_filters.py +++ b/tests/core/test_template_tags_filters.py @@ -8,10 +8,10 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.template import Template, Context +from django.template import Context, Template -from openslides.utils.test import TestCase from openslides.config.api import config +from openslides.utils.test import TestCase from .models import TestModel diff --git a/tests/core/test_views.py b/tests/core/test_views.py index d8eb18152..687b8eeee 100644 --- a/tests/core/test_views.py +++ b/tests/core/test_views.py @@ -10,14 +10,14 @@ from django.test.client import Client -from openslides.utils.test import TestCase from openslides import get_version from openslides.participant.models import User +from openslides.utils.test import TestCase class VersionViewTest(TestCase): def test_get(self): - user = User.objects.create_user('CoreMaximilian', 'xxx@xx.xx', 'default') + User.objects.create_user('CoreMaximilian', 'xxx@xx.xx', 'default') client = Client() client.login(username='CoreMaximilian', password='default') response = client.get('/version/') diff --git a/tests/forms/test_clean_html.py b/tests/forms/test_clean_html.py index c59621d0d..22b2502bd 100644 --- a/tests/forms/test_clean_html.py +++ b/tests/forms/test_clean_html.py @@ -8,10 +8,9 @@ """ from django import forms -from django.db import models -from openslides.utils.test import TestCase from openslides.utils.forms import CleanHtmlFormMixin +from openslides.utils.test import TestCase class HtmlTestForm(CleanHtmlFormMixin, forms.Form): diff --git a/tests/mediafile/tests.py b/tests/mediafile/tests.py index 7b8177aac..344246ac1 100644 --- a/tests/mediafile/tests.py +++ b/tests/mediafile/tests.py @@ -13,15 +13,15 @@ import os import tempfile -from django.test.client import Client -from django.core.files.uploadedfile import SimpleUploadedFile from django.conf import settings -from django.contrib.contenttypes.models import ContentType from django.contrib.auth.models import Permission +from django.contrib.contenttypes.models import ContentType +from django.core.files.uploadedfile import SimpleUploadedFile +from django.test.client import Client -from openslides.utils.test import TestCase from openslides.mediafile.models import Mediafile from openslides.participant.models import User +from openslides.utils.test import TestCase class MediafileTest(TestCase): @@ -33,7 +33,6 @@ class MediafileTest(TestCase): ct = ContentType.objects.get(app_label='mediafile', model='mediafile') perm_1 = Permission.objects.get(content_type=ct, codename='can_see') perm_2 = Permission.objects.get(content_type=ct, codename='can_upload') - perm_3 = Permission.objects.get(content_type=ct, codename='can_manage') # Setup three different users self.manager = User.objects.get(pk=1) diff --git a/tests/motion/test_csv_import.py b/tests/motion/test_csv_import.py index 008998cd4..3966a00c1 100644 --- a/tests/motion/test_csv_import.py +++ b/tests/motion/test_csv_import.py @@ -8,14 +8,13 @@ :license: GNU GPL, see LICENSE for more details. """ -import StringIO import os +import StringIO from django.test.client import Client -from openslides.config.api import config -from openslides.motion.models import Motion, Category from openslides.motion.csv_import import import_motions +from openslides.motion.models import Category, Motion from openslides.participant.models import User from openslides.utils.test import TestCase diff --git a/tests/motion/test_models.py b/tests/motion/test_models.py index 943f9f481..0f654ec9b 100644 --- a/tests/motion/test_models.py +++ b/tests/motion/test_models.py @@ -8,11 +8,11 @@ :license: GNU GPL, see LICENSE for more details. """ -from openslides.utils.test import TestCase -from openslides.participant.models import User from openslides.config.api import config -from openslides.motion.models import Motion, Workflow, State from openslides.motion.exceptions import WorkflowError +from openslides.motion.models import Motion, State, Workflow +from openslides.participant.models import User +from openslides.utils.test import TestCase class ModelTest(TestCase): @@ -58,7 +58,6 @@ class ModelTest(TestCase): motion.title = 'v2' motion.save(use_version=motion.get_new_version()) - v2_version = motion.get_last_version() motion.title = 'v3' motion.save(use_version=motion.get_new_version()) with self.assertRaises(AttributeError): @@ -122,8 +121,8 @@ class ModelTest(TestCase): state_1.save() def test_two_empty_identifiers(self): - motion1 = Motion.objects.create(title='foo', text='bar', identifier='') - motion2 = Motion.objects.create(title='foo2', text='bar2', identifier='') + Motion.objects.create(title='foo', text='bar', identifier='') + Motion.objects.create(title='foo2', text='bar2', identifier='') def test_do_not_create_new_version_when_permit_old_version(self): motion = Motion() diff --git a/tests/motion/test_views.py b/tests/motion/test_views.py index 859e6c6dd..b75eff531 100644 --- a/tests/motion/test_views.py +++ b/tests/motion/test_views.py @@ -11,9 +11,9 @@ from django.test.client import Client from openslides.config.api import config +from openslides.motion.models import Category, Motion, MotionLog, State +from openslides.participant.models import Group, User from openslides.utils.test import TestCase -from openslides.participant.models import User, Group -from openslides.motion.models import Motion, State, Category, MotionLog class MotionViewTestCase(TestCase): @@ -152,9 +152,9 @@ class TestMotionCreateView(MotionViewTestCase): def test_log(self): self.assertFalse(MotionLog.objects.all().exists()) - response = self.admin_client.post(self.url, {'title': 'new motion', - 'text': 'motion text', - 'workflow': 1}) + self.admin_client.post(self.url, {'title': 'new motion', + 'text': 'motion text', + 'workflow': 1}) self.assertEqual(MotionLog.objects.get(pk=1).message_list, ['Motion created']) @@ -328,39 +328,39 @@ class TestMotionUpdateView(MotionViewTestCase): # Update motion without versioning self.assertFalse(self.motion1.state.versioning) - response = self.admin_client.post(self.url, {'title': 'new motion_title', - 'text': 'motion text', - 'workflow': 2}) + self.admin_client.post(self.url, {'title': 'new motion_title', + 'text': 'motion text', + 'workflow': 2}) self.assertEqual(MotionLog.objects.get(pk=1).message_list, ['Motion version', ' 1 ', 'updated']) # Update motion by creating a new version self.motion1.set_state(6) # Set to state 'permitted' which has versioning=True self.assertTrue(self.motion1.state.versioning) self.motion1.save(use_version=False) - response = self.admin_client.post(self.url, {'title': 'new motion_title', - 'text': 'new motion text', - 'workflow': 2}) + self.admin_client.post(self.url, {'title': 'new motion_title', + 'text': 'new motion text', + 'workflow': 2}) self.assertEqual(MotionLog.objects.get(pk=2).message_list, ['Motion version', ' 2 ', 'created']) # Update motion with so called 'trivial changes' config['motion_allow_disable_versioning'] = True - response = self.admin_client.post(self.url, {'title': 'new motion_title', - 'text': 'more new motion text', - 'disable_versioning': 'on', - 'workflow': 2}) + self.admin_client.post(self.url, {'title': 'new motion_title', + 'text': 'more new motion text', + 'disable_versioning': 'on', + 'workflow': 2}) self.assertEqual(MotionLog.objects.get(pk=3).message_list, ['Motion version', ' 2 ', 'updated']) # Update motion without changes in the version data - response = self.admin_client.post(self.url, {'title': 'new motion_title', - 'text': 'more new motion text', - 'workflow': 2}) + self.admin_client.post(self.url, {'title': 'new motion_title', + 'text': 'more new motion text', + 'workflow': 2}) self.assertEqual(MotionLog.objects.get(pk=4).message_list, ['Motion version', ' 2 ', 'updated']) # Update motion without changes in the version data but also with the 'trivial changes' flag - response = self.admin_client.post(self.url, {'title': 'new motion_title', - 'text': 'more new motion text', - 'disable_versioning': 'on', - 'workflow': 2}) + self.admin_client.post(self.url, {'title': 'new motion_title', + 'text': 'more new motion text', + 'disable_versioning': 'on', + 'workflow': 2}) self.assertEqual(MotionLog.objects.get(pk=5).message_list, ['Motion version', ' 2 ', 'updated']) @@ -376,7 +376,7 @@ class TestMotionDeleteView(MotionViewTestCase): def test_delegate(self): response = self.delegate_client.post('/motion/2/del/', {'yes': 'yes'}) self.assertEqual(response.status_code, 403) - motion = Motion.objects.get(pk=2).add_submitter(self.delegate) + Motion.objects.get(pk=2).add_submitter(self.delegate) response = self.delegate_client.post('/motion/2/del/', {'yes': 'yes'}) self.assertEqual(response.status_code, 403) @@ -404,7 +404,7 @@ class TestVersionPermitView(MotionViewTestCase): self.motion1.active_version = new_version self.motion1.save() self.assertEqual(self.motion1.versions.count(), 2) - response = self.admin_client.post('/motion/1/version/1/permit/', {'yes': 1}) + self.admin_client.post('/motion/1/version/1/permit/', {'yes': 1}) self.motion1 = Motion.objects.get(pk=1) self.assertEqual(self.motion1.active_version, first_version) self.assertEqual(self.motion1.versions.count(), 2) diff --git a/tests/participant/test_models.py b/tests/participant/test_models.py index d9b5a2cf0..8f898d1a4 100644 --- a/tests/participant/test_models.py +++ b/tests/participant/test_models.py @@ -8,12 +8,10 @@ :license: GNU GPL, see LICENSE for more details. """ -from openslides.utils.test import TestCase - +from openslides.participant.api import gen_password, gen_username +from openslides.participant.models import Group, User from openslides.utils.person import get_person, Persons - -from openslides.participant.models import User, Group -from openslides.participant.api import gen_username, gen_password +from openslides.utils.test import TestCase class UserTest(TestCase): diff --git a/tests/participant/test_umlaut_user.py b/tests/participant/test_umlaut_user.py index f65e1314d..e13ffbc88 100644 --- a/tests/participant/test_umlaut_user.py +++ b/tests/participant/test_umlaut_user.py @@ -10,9 +10,8 @@ from django.test.client import Client +from openslides.participant.models import Group, User from openslides.utils.test import TestCase -from openslides.config.api import config -from openslides.participant.models import User, Group class TestUmlautUser(TestCase): diff --git a/tests/participant/test_utils.py b/tests/participant/test_utils.py index ace52e737..ae2417d6c 100644 --- a/tests/participant/test_utils.py +++ b/tests/participant/test_utils.py @@ -8,10 +8,9 @@ :license: GNU GPL, see LICENSE for more details. """ -from openslides.utils.test import TestCase - -from openslides.participant.models import User from openslides.participant.api import gen_username +from openslides.participant.models import User +from openslides.utils.test import TestCase class UserGenUsername(TestCase): diff --git a/tests/participant/test_views.py b/tests/participant/test_views.py index 1a695c748..38ae8b18f 100644 --- a/tests/participant/test_views.py +++ b/tests/participant/test_views.py @@ -9,11 +9,12 @@ """ import re + from django.test.client import Client from openslides.config.api import config +from openslides.participant.models import get_protected_perm, Group, User from openslides.utils.test import TestCase -from openslides.participant.models import User, Group, get_protected_perm class GroupViews(TestCase): diff --git a/tests/person_api/models.py b/tests/person_api/models.py index 57793b8e2..230d59bbd 100644 --- a/tests/person_api/models.py +++ b/tests/person_api/models.py @@ -1,9 +1,8 @@ from django.db import models from django.dispatch import receiver -from openslides.utils.person.models import PersonMixin, PersonField +from openslides.utils.person.models import PersonField, PersonMixin from openslides.utils.person.signals import receive_persons -from openslides.utils.person.api import Person class TestPerson(PersonMixin, models.Model): diff --git a/tests/person_api/tests.py b/tests/person_api/tests.py index e1e15c237..78c11fef3 100644 --- a/tests/person_api/tests.py +++ b/tests/person_api/tests.py @@ -10,14 +10,12 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.test.client import Client -from django.db.models.query import EmptyQuerySet from django.contrib.auth.models import AnonymousUser -from openslides.utils.test import TestCase from openslides.utils.person.api import get_person +from openslides.utils.test import TestCase -from .models import TestPerson, TestModel +from .models import TestModel, TestPerson class PersonTest(TestCase): diff --git a/tests/projector/test_widgets.py b/tests/projector/test_widgets.py index f0bdcb9f4..14284d2eb 100644 --- a/tests/projector/test_widgets.py +++ b/tests/projector/test_widgets.py @@ -20,7 +20,7 @@ from openslides.utils.test import TestCase class WidgetObject(TestCase): def test_error(self): with self.assertRaises(OpenSlidesError): - w = Widget(HttpRequest(), name='chahghuyeim8ie0Noong') + Widget(HttpRequest(), name='chahghuyeim8ie0Noong') def test_repr(self): w = Widget(HttpRequest(), name='abcdefgäöüß', html='html') diff --git a/tests/settings.py b/tests/settings.py index ffeb82346..26e64edd4 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import openslides.main -from openslides.global_settings import * +from openslides.global_settings import * # noqa # Use 'DEBUG = True' to get more details for server errors # (Default for releases: 'False') diff --git a/tests/test_init.py b/tests/test_init.py index aa665c62f..0683d8dd1 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -7,7 +7,7 @@ :license: GNU GPL, see LICENSE for more details. """ -from openslides import get_version, get_git_commit_id +from openslides import get_git_commit_id, get_version from openslides.utils.test import TestCase diff --git a/tests/utils/test_views.py b/tests/utils/test_views.py index 111477741..0a0521ff0 100644 --- a/tests/utils/test_views.py +++ b/tests/utils/test_views.py @@ -10,16 +10,12 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.contrib.messages.storage import default_storage from django.core.exceptions import ImproperlyConfigured from django.core.urlresolvers import clear_url_caches -from django.dispatch import receiver -from django.http.response import HttpResponseNotAllowed from django.test import RequestFactory from django.test.client import Client from django.test.utils import override_settings -from openslides.participant.models import User from openslides.utils import views from openslides.utils.signals import template_manipulation from openslides.utils.test import TestCase @@ -38,7 +34,6 @@ class ViewTestCase(TestCase): class LoginMixinTest(ViewTestCase): def test_dispatch(self): - view = test_views.LoginMixinView.as_view() client = Client() response = client.get('/login_mixin/') self.assertEqual(response['Location'], 'http://testserver/login/?next=/login_mixin/')