Merge pull request #894 from ostcar/pylint

Cleanups
This commit is contained in:
Oskar Hahn 2013-10-14 09:47:02 -07:00
commit 21da6c24a8
94 changed files with 600 additions and 726 deletions

10
fabfile.py vendored
View File

@ -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):

View File

@ -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

View File

@ -12,4 +12,4 @@
:license: GNU GPL, see LICENSE for more details.
"""
from . import signals, slides
from . import signals, slides # noqa

View File

@ -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

View File

@ -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):

View File

@ -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):

View File

@ -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

View File

@ -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<pk>\d+)/$',
AgendaItemView.as_view(),
name='item_view',
),
views.AgendaItemView.as_view(),
name='item_view'),
url(r'^(?P<pk>\d+)/close/$',
SetClosed.as_view(),
views.SetClosed.as_view(),
{'closed': True},
name='item_close',
),
name='item_close'),
url(r'^(?P<pk>\d+)/open/$',
SetClosed.as_view(),
views.SetClosed.as_view(),
{'closed': False},
name='item_open',
),
name='item_open'),
url(r'^(?P<pk>\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<pk>\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<pk>\d+)/speaker/$',
SpeakerAppendView.as_view(),
name='agenda_speaker_append',
),
views.SpeakerAppendView.as_view(),
name='agenda_speaker_append'),
url(r'^(?P<pk>\d+)/speaker/close/$',
SpeakerListCloseView.as_view(),
name='agenda_speaker_close',
),
views.SpeakerListCloseView.as_view(),
name='agenda_speaker_close'),
url(r'^(?P<pk>\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<pk>\d+)/speaker/del/$',
SpeakerDeleteView.as_view(),
name='agenda_speaker_delete',
),
views.SpeakerDeleteView.as_view(),
name='agenda_speaker_delete'),
url(r'^(?P<pk>\d+)/speaker/(?P<speaker>\d+)/del/$',
SpeakerDeleteView.as_view(),
name='agenda_speaker_delete',
),
views.SpeakerDeleteView.as_view(),
name='agenda_speaker_delete'),
url(r'^(?P<pk>\d+)/speaker/(?P<person_id>[^/]+)/speak/$',
SpeakerSpeakView.as_view(),
name='agenda_speaker_speak',
),
views.SpeakerSpeakView.as_view(),
name='agenda_speaker_speak'),
url(r'^(?P<pk>\d+)/speaker/end_speach/$',
SpeakerEndSpeachView.as_view(),
name='agenda_speaker_end_speach',
),
views.SpeakerEndSpeachView.as_view(),
name='agenda_speaker_end_speach'),
url(r'^(?P<pk>\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')
)

View File

@ -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()

View File

@ -10,5 +10,4 @@
:license: GNU GPL, see LICENSE for more details.
"""
from . import signals
from . import slides
from . import signals, slides # noqa

View File

@ -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):

View File

@ -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):

View File

@ -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')

View File

@ -11,7 +11,7 @@
"""
from openslides.projector.api import register_slide_model
from .models import Assignment
register_slide_model(Assignment, 'assignment/slide.html')

View File

@ -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<pk>\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<pk>\d+)/edit/$',
AssignmentUpdateView.as_view(),
name='assignment_update',
),
views.AssignmentUpdateView.as_view(),
name='assignment_update'),
url(r'^(?P<pk>\d+)/del/$',
AssignmentDeleteView.as_view(),
name='assignment_delete',
),
views.AssignmentDeleteView.as_view(),
name='assignment_delete'),
url(r'^(?P<pk>\d+)/setstatus/(?P<status>[a-z]{3})/$',
AssignmentSetStatusView.as_view(),
name='assignment_set_status',
),
views.AssignmentSetStatusView.as_view(),
name='assignment_set_status'),
url(r'^(?P<pk>\d+)/run/$',
AssignmentRunView.as_view(),
name='assignment_run',
),
views.AssignmentRunView.as_view(),
name='assignment_run'),
url(r'^(?P<pk>\d+)/delrun/$',
AssignmentRunDeleteView.as_view(),
name='assignment_delrun',
),
views.AssignmentRunDeleteView.as_view(),
name='assignment_delrun'),
url(r'^(?P<pk>\d+)/delother/(?P<user_id>[^/]+)/$',
AssignmentRunOtherDeleteView.as_view(),
name='assignment_delother',
),
views.AssignmentRunOtherDeleteView.as_view(),
name='assignment_delother'),
url(r'^poll/(?P<poll_id>\d+)/print/$',
AssignmentPollPDF.as_view(),
name='assignment_poll_pdf',
),
views.AssignmentPollPDF.as_view(),
name='assignment_poll_pdf'),
url(r'^(?P<pk>\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<pk>\d+)/print/$',
AssignmentPDF.as_view(),
name='assignment_pdf',
),
views.AssignmentPDF.as_view(),
name='assignment_pdf'),
url(r'^(?P<pk>\d+)/gen_poll/$',
PollCreateView.as_view(),
name='assignment_poll_create',
),
views.PollCreateView.as_view(),
name='assignment_poll_create'),
url(r'^poll/(?P<poll_id>\d+)/$',
PollUpdateView.as_view(),
name='assignment_poll_view',
),
views.PollUpdateView.as_view(),
name='assignment_poll_view'),
url(r'^poll/(?P<pk>\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<pk>\d+)/pub/$',
SetPublishStatusView.as_view(),
name='assignment_poll_publish_status',
),
views.SetPublishStatusView.as_view(),
name='assignment_poll_publish_status'),
url(r'^(?P<pk>\d+)/elected/(?P<user_id>[^/]+)/$',
SetElectedView.as_view(),
views.SetElectedView.as_view(),
{'elected': True},
name='assignment_user_elected',
),
name='assignment_user_elected'),
url(r'^(?P<pk>\d+)/notelected/(?P<user_id>[^/]+)/$',
SetElectedView.as_view(),
views.SetElectedView.as_view(),
{'elected': False},
name='assignment_user_not_elected',
),
name='assignment_user_not_elected')
)

View File

@ -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):

View File

@ -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

View File

@ -12,6 +12,5 @@
from django.dispatch import Signal
config_signal = Signal(providing_args=[])
"""Signal to get all config tabs from all apps."""

View File

@ -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'):

View File

@ -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

View File

@ -10,4 +10,4 @@
:license: GNU GPL, see LICENSE for more details.
"""
from . import signals
from . import signals # noqa

View File

@ -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):

View File

@ -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()

View File

@ -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]

View File

@ -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',),
)

View File

@ -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

View File

@ -11,8 +11,6 @@
"""
import os
import sys
from openslides.main import fs2unicode

View File

@ -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

View File

@ -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<pk>\d+)/edit/$',
MediafileUpdateView.as_view(),
name='mediafile_update',
),
views.MediafileUpdateView.as_view(),
name='mediafile_update'),
url(r'^(?P<pk>\d+)/del/$',
MediafileDeleteView.as_view(),
name='mediafile_delete',
),
views.MediafileDeleteView.as_view(),
name='mediafile_delete'),
)

View File

@ -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):

View File

@ -11,4 +11,4 @@
:license: GNU GPL, see LICENSE for more details.
"""
from . import signals, slides
from . import signals, slides # noqa

View File

@ -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):

View File

@ -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

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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')

View File

@ -11,6 +11,7 @@
"""
from openslides.projector.api import register_slide_model
from .models import Motion
register_slide_model(Motion, 'motion/slide.html')

View File

@ -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<pk>\d+)/$',
'motion_detail',
name='motion_detail',
),
name='motion_detail'),
url(r'^(?P<pk>\d+)/edit/$',
'motion_update',
name='motion_update',
),
name='motion_update'),
url(r'^(?P<pk>\d+)/del/$',
'motion_delete',
name='motion_delete',
),
name='motion_delete'),
url(r'^(?P<pk>\d+)/version/(?P<version_number>\d+)/$',
'motion_detail',
name='motion_version_detail',
),
name='motion_version_detail'),
url(r'^(?P<pk>\d+)/version/(?P<version_number>\d+)/permit/$',
'version_permit',
name='motion_version_permit',
),
name='motion_version_permit'),
url(r'^(?P<pk>\d+)/version/(?P<version_number>\d+)/del/$',
'version_delete',
name='motion_version_delete',
),
name='motion_version_delete'),
url(r'^(?P<pk>\d+)/diff/$',
'version_diff',
name='motion_version_diff',
),
name='motion_version_diff'),
url(r'^(?P<pk>\d+)/support/$',
'motion_support',
name='motion_support',
),
name='motion_support'),
url(r'^(?P<pk>\d+)/unsupport/$',
'motion_unsupport',
name='motion_unsupport',
),
name='motion_unsupport'),
url(r'^(?P<pk>\d+)/create_poll/$',
'poll_create',
name='motion_poll_create',
),
name='motion_poll_create'),
url(r'^(?P<pk>\d+)/poll/(?P<poll_number>\d+)/edit/$',
'poll_update',
name='motion_poll_update',
),
name='motion_poll_update'),
url(r'^(?P<pk>\d+)/poll/(?P<poll_number>\d+)/del/$',
'poll_delete',
name='motion_poll_delete',
),
name='motion_poll_delete'),
url(r'^(?P<pk>\d+)/poll/(?P<poll_number>\d+)/pdf/$',
'poll_pdf',
name='motion_poll_pdf',
),
name='motion_poll_pdf'),
url(r'^(?P<pk>\d+)/set_state/(?P<state>\d+)/$',
'set_state',
name='motion_set_state',
),
name='motion_set_state'),
url(r'^(?P<pk>\d+)/reset_state/$',
'reset_state',
name='motion_reset_state',
),
name='motion_reset_state'),
url(r'^(?P<pk>\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<pk>\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<pk>\d+)/edit/$',
'category_update',
name='motion_category_update',
),
name='motion_category_update'),
url(r'^category/(?P<pk>\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'),
)

View File

@ -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):

View File

@ -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

View File

@ -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():

View File

@ -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):

View File

@ -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):

View File

@ -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')

View File

@ -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')

View File

@ -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<pk>\d+)/$',
UserDetailView.as_view(),
name='user_view',
),
views.UserDetailView.as_view(),
name='user_view'),
url(r'^(?P<pk>\d+)/edit/$',
UserUpdateView.as_view(),
name='user_edit',
),
views.UserUpdateView.as_view(),
name='user_edit'),
url(r'^(?P<pk>\d+)/del/$',
UserDeleteView.as_view(),
name='user_delete',
),
views.UserDeleteView.as_view(),
name='user_delete'),
url(r'^(?P<pk>\d+)/reset_password/$',
ResetPasswordView.as_view(),
name='user_reset_password',
),
views.ResetPasswordView.as_view(),
name='user_reset_password'),
url(r'^(?P<pk>\d+)/status/activate/$',
SetUserStatusView.as_view(),
views.SetUserStatusView.as_view(),
{'action': 'activate'},
name='user_status_activate',
),
name='user_status_activate'),
url(r'^(?P<pk>\d+)/status/deactivate/$',
SetUserStatusView.as_view(),
views.SetUserStatusView.as_view(),
{'action': 'deactivate'},
name='user_status_deactivate',
),
name='user_status_deactivate'),
url(r'^(?P<pk>\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<pk>\d+)/$',
GroupDetailView.as_view(),
name='user_group_view',
),
views.GroupDetailView.as_view(),
name='user_group_view'),
url(r'^group/(?P<pk>\d+)/edit/$',
GroupUpdateView.as_view(),
name='user_group_edit',
),
views.GroupUpdateView.as_view(),
name='user_group_edit'),
url(r'^group/(?P<pk>\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'),
)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -10,4 +10,4 @@
:license: GNU GPL, see LICENSE for more details.
"""
from . import signals, slides
from . import signals, slides # noqa

View File

@ -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()

View File

@ -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.
"""

View File

@ -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):
"""

View File

@ -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 = '<div id="overlay_%s">%s</div>' % (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

View File

@ -9,37 +9,31 @@
:copyright: 20112013 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.

View File

@ -14,5 +14,4 @@ from openslides.projector.api import register_slide_model
from .models import ProjectorSlide
register_slide_model(ProjectorSlide, 'projector/slide_projectorslide.html')

View File

@ -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<callback>[^/]*)/$',
Projector.as_view(),
name='projector_preview',
),
views.Projector.as_view(),
name='projector_preview'),
url(r'^activate/(?P<callback>[^/]*)/$',
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<pk>\d+)/edit/$',
CustomSlideUpdateView.as_view(),
name='customslide_edit',
),
views.CustomSlideUpdateView.as_view(),
name='customslide_edit'),
url(r'^(?P<pk>\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<name>[^/]*)/activate/$',
ActivateOverlay.as_view(),
views.ActivateOverlay.as_view(),
{'activate': True},
name='projector_overlay_activate',
),
name='projector_overlay_activate'),
url('^overlay/(?P<name>[^/]*)/deactivate/$',
ActivateOverlay.as_view(),
views.ActivateOverlay.as_view(),
{'activate': False},
name='projector_overlay_deactivate',
),
name='projector_overlay_deactivate'),
)

View File

@ -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', {})

View File

@ -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')),
)

View File

@ -11,6 +11,7 @@
"""
from django.contrib.auth.models import Permission
from openslides.config.api import config

View File

@ -5,4 +5,4 @@
:license: GNU GPL, see LICENSE for more details.
"""
from AnonymousAuth import *
from AnonymousAuth import * # noqa

View File

@ -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.

View File

@ -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):

View File

@ -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')))

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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

View File

@ -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/')

View File

@ -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):

View File

@ -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)

View File

@ -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

View File

@ -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()

View File

@ -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)

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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='<strong>html</strong>')

View File

@ -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')

View File

@ -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

View File

@ -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/')