diff --git a/openslides/__init__.py b/openslides/__init__.py index a5bc6b52b..8ba881ae8 100644 --- a/openslides/__init__.py +++ b/openslides/__init__.py @@ -55,7 +55,6 @@ def hg_version(): try: ui = hgui.ui() repository = localrepository(ui, join(conts, '..')) - #repository = localrepository(ui, conts) ctx = repository['.'] if ctx.tags() and ctx.tags() != ['tip']: version = ' '.join(ctx.tags()) @@ -77,7 +76,7 @@ def hg_version(): return version -import os, site - -SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) -site.addsitedir(SITE_ROOT) +## import os, site +## +## SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) +## site.addsitedir(SITE_ROOT) diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index 0c871dd99..32ec36a0b 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -104,23 +104,12 @@ class Item(MPTTModel, SlideMixin): self.closed = closed self.save() - ## @property - ## def active_parent(self): - ## """ - ## Return True if the item has an active parent. - ## """ - ## sid = get_active_slide(only_sid=True).split() - ## if len(sid) == 2 and sid[0] == self.prefix: - ## if self.get_ancestors().filter(pk=sid[0]).exists(): - ## return True - ## return False - @property def weight_form(self): """ Return the WeightForm for this item. """ - from agenda.forms import ItemOrderForm + from openslides.agenda.forms import ItemOrderForm try: parent = self.parent.id except AttributeError: diff --git a/openslides/agenda/urls.py b/openslides/agenda/urls.py index 3fa098962..6022bff4d 100644 --- a/openslides/agenda/urls.py +++ b/openslides/agenda/urls.py @@ -11,8 +11,8 @@ """ from django.conf.urls.defaults import url, patterns -from agenda.views import (Overview, View, SetClosed, ItemUpdate, ItemCreate, - ItemDelete, AgendaPDF) +from openslides.agenda.views import (Overview, View, SetClosed, ItemUpdate, + ItemCreate, ItemDelete, AgendaPDF) urlpatterns = patterns('', url(r'^$', diff --git a/openslides/application/urls.py b/openslides/application/urls.py index 1ccefbbbd..3b3e83e9e 100644 --- a/openslides/application/urls.py +++ b/openslides/application/urls.py @@ -12,10 +12,10 @@ from django.conf.urls.defaults import url, patterns -from application.views import (ApplicationDelete, ViewPoll, ApplicationPDF, - ApplicationPollPDF, CreateAgendaItem) +from openslides.application.views import (ApplicationDelete, ViewPoll, + ApplicationPDF, ApplicationPollPDF, CreateAgendaItem) -urlpatterns = patterns('application.views', +urlpatterns = patterns('openslides.application.views', url(r'^$', 'overview', name='application_overview', diff --git a/openslides/assignment/forms.py b/openslides/assignment/forms.py index 2c4b6c7b9..b771a41b4 100644 --- a/openslides/assignment/forms.py +++ b/openslides/assignment/forms.py @@ -13,10 +13,10 @@ from django import forms from django.utils.translation import ugettext_lazy as _, ugettext_noop -from utils.forms import CssClassMixin +from openslides.utils.forms import CssClassMixin -from participant.models import Profile -from assignment.models import Assignment +from openslides.participant.models import Profile +from openslides.assignment.models import Assignment class AssignmentForm(forms.ModelForm, CssClassMixin): diff --git a/openslides/assignment/models.py b/openslides/assignment/models.py index 21eb10d7b..eaa3207d1 100644 --- a/openslides/assignment/models.py +++ b/openslides/assignment/models.py @@ -26,7 +26,7 @@ from openslides.participant.models import Profile from openslides.poll.models import (BasePoll, CountInvalid, CountVotesCast, BaseOption, PublishPollMixin) -from agenda.models import Item +from openslides.agenda.models import Item class Assignment(models.Model, SlideMixin): diff --git a/openslides/assignment/urls.py b/openslides/assignment/urls.py index e8887f101..0b6e63798 100644 --- a/openslides/assignment/urls.py +++ b/openslides/assignment/urls.py @@ -12,10 +12,10 @@ from django.conf.urls.defaults import url, patterns -from assignment.views import (ViewPoll, AssignmentPDF, AssignmentPollPDF, - AssignmentPollDelete, CreateAgendaItem) +from openslides.assignment.views import (ViewPoll, AssignmentPDF, + AssignmentPollPDF, AssignmentPollDelete, CreateAgendaItem) -urlpatterns = patterns('assignment.views', +urlpatterns = patterns('openslides.assignment.views', url(r'^$', 'get_overview', name='assignment_overview', diff --git a/openslides/assignment/views.py b/openslides/assignment/views.py index 9f54de109..029e93a0c 100644 --- a/openslides/assignment/views.py +++ b/openslides/assignment/views.py @@ -25,11 +25,11 @@ from django.contrib.auth.models import User from django.shortcuts import redirect from django.utils.translation import ungettext, ugettext as _ -from utils.pdf import stylesheet -from utils.template import Tab -from utils.utils import (template, permission_required, gen_confirm_form, - del_confirm_form, ajax_request) -from utils.views import FormView, DeleteView, PDFView, RedirectView +from openslides.utils.pdf import stylesheet +from openslides.utils.template import Tab +from openslides.utils.utils import (template, permission_required, + gen_confirm_form, del_confirm_form, ajax_request) +from openslides.utils.views import FormView, DeleteView, PDFView, RedirectView from openslides.config.models import config from openslides.participant.models import Profile diff --git a/openslides/config/models.py b/openslides/config/models.py index c4c6df33f..cfc953bf2 100644 --- a/openslides/config/models.py +++ b/openslides/config/models.py @@ -116,7 +116,8 @@ def set_submenu(sender, request, context, **kwargs): except (ImportError, AttributeError): continue - appname = mod.__name__.split('.')[0] + appname = mod.__name__.split('.')[-1] + selected = reverse('config_%s' % appname) == request.path try: title = mod.NAME diff --git a/openslides/config/urls.py b/openslides/config/urls.py index 727fafadb..14659f5a8 100644 --- a/openslides/config/urls.py +++ b/openslides/config/urls.py @@ -33,7 +33,7 @@ for app in settings.INSTALLED_APPS: mod = import_module(app + '.views') except ImportError: continue - appname = mod.__name__.split('.')[0] + appname = mod.__name__.split('.')[-2] try: urlpatterns += patterns('', url( r'^%s/$' % appname, diff --git a/openslides/main.py b/openslides/main.py index 192d826fd..9f3f94301 100644 --- a/openslides/main.py +++ b/openslides/main.py @@ -10,6 +10,7 @@ :license: GNU GPL, see LICENSE for more details. """ +# for python 2.5 support from __future__ import with_statement import os @@ -72,6 +73,7 @@ def main(argv = None): start_browser(url) execute_from_command_line(argv) + def detect_listen_opts(address, port): if address is None: try: @@ -93,6 +95,7 @@ def detect_listen_opts(address, port): return address, port + def start_browser(url): browser = webbrowser.get() def f(): @@ -102,6 +105,7 @@ def start_browser(url): t = threading.Thread(target = f) t.start() + def prepare_openslides(url, always_syncdb = False): settings_module = os.environ.get(django.conf.ENVIRONMENT_VARIABLE) if not settings_module: @@ -140,6 +144,7 @@ def prepare_openslides(url, always_syncdb = False): create_or_reset_admin_user() return True + def run_syncdb(url): # now initialize the database argv = ["", "syncdb", "--noinput"] @@ -147,6 +152,7 @@ def run_syncdb(url): set_system_url(url) + def check_database(url): """Detect if database was deleted and recreate if necessary""" # can't be imported in global scope as they already require @@ -162,6 +168,7 @@ def check_database(url): return True return False + def create_or_reset_admin_user(): # can't be imported in global scope as it already requires # the settings module during import @@ -180,6 +187,7 @@ def create_or_reset_admin_user(): obj.set_password("admin") obj.save() + def set_system_url(url): # can't be imported in global scope as it already requires # the settings module during import @@ -196,5 +204,6 @@ def generate_secret_key(): chars = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)" return get_random_string(50, chars) + if __name__ == "__main__": main() diff --git a/openslides/openslides_settings.py b/openslides/openslides_settings.py index da61bdf5c..15d8151ea 100755 --- a/openslides/openslides_settings.py +++ b/openslides/openslides_settings.py @@ -12,7 +12,6 @@ import os import sys -from django.conf.global_settings import * _fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() def _fs2unicode(s): @@ -21,11 +20,10 @@ def _fs2unicode(s): return s.decode(_fs_encoding) SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) -#SITE_ROOT = os.path.join(SITE_ROOT, '..') - AUTH_PROFILE_MODULE = 'participant.Profile' -AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend', 'openslides.utils.auth.AnonymousAuth',) +AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend', + 'openslides.utils.auth.AnonymousAuth',) LOGIN_URL = '/login/' LOGIN_REDIRECT_URL = '/' @@ -34,16 +32,15 @@ DBPATH = _fs2unicode(os.path.join(os.path.join(SITE_ROOT, '..'), 'database.db')) DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. - 'NAME': DBPATH, # Or path to database file if using sqlite3. - 'USER': '', # Not used with sqlite3. - 'PASSWORD': '', # Not used with sqlite3. - 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. - 'PORT': '', # Set to empty string for default. Not used with sqlite3. + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': DBPATH, + 'USER': '', + 'PASSWORD': '', + 'HOST': '', + 'PORT': '', } } - ugettext = lambda s: s LANGUAGES = ( @@ -111,7 +108,8 @@ MIDDLEWARE_CLASSES = ( ROOT_URLCONF = 'openslides.urls' TEMPLATE_DIRS = ( - # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". + # Put strings here, like "/home/html/django_templates" or + # "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. _fs2unicode(os.path.join(SITE_ROOT, 'templates')), @@ -124,14 +122,14 @@ INSTALLED_APPS = ( 'django.contrib.messages', 'django.contrib.staticfiles', 'mptt', - 'utils', - 'poll', - 'projector', - 'agenda', - 'application', - 'assignment', - 'participant', - 'config', + 'openslides.utils', + 'openslides.poll', + 'openslides.projector', + 'openslides.agenda', + 'openslides.application', + 'openslides.assignment', + 'openslides.participant', + 'openslides.config', ) TEMPLATE_CONTEXT_PROCESSORS = ( @@ -140,6 +138,6 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.request', 'django.core.context_processors.i18n', 'django.core.context_processors.static', - 'utils.utils.revision', + 'openslides.utils.utils.revision', 'openslides.utils.auth.anonymous_context_additions', ) diff --git a/openslides/participant/urls.py b/openslides/participant/urls.py index b779b5e53..e0245d575 100644 --- a/openslides/participant/urls.py +++ b/openslides/participant/urls.py @@ -13,9 +13,10 @@ from django.conf.urls.defaults import url, patterns from django.core.urlresolvers import reverse -from participant.views import ParticipantsListPDF, ParticipantsPasswordsPDF +from openslides.participant.views import (ParticipantsListPDF, + ParticipantsPasswordsPDF) -urlpatterns = patterns('participant.views', +urlpatterns = patterns('openslides.participant.views', url(r'^$', 'get_overview', name='user_overview', diff --git a/openslides/poll/models.py b/openslides/poll/models.py index 3b1e9093c..8ad108258 100644 --- a/openslides/poll/models.py +++ b/openslides/poll/models.py @@ -160,7 +160,7 @@ class BasePoll(models.Model): """ Return the form for one option of the poll. """ - from poll.forms import OptionForm + from openslides.poll.forms import OptionForm return OptionForm(extra=self.get_form_values(kwargs['formid']), **kwargs) diff --git a/openslides/projector/urls.py b/openslides/projector/urls.py index 481a4d5df..efba5bbf0 100644 --- a/openslides/projector/urls.py +++ b/openslides/projector/urls.py @@ -17,7 +17,7 @@ from openslides.projector.views import (ControlView, ActivateView, CountdownEdit, ProjectorEdit, Projector, ActivateOverlay) -urlpatterns = patterns('projector.views', +urlpatterns = patterns('', url(r'^$', Projector.as_view(), {'sid': None}, diff --git a/openslides/urls.py b/openslides/urls.py index c47cc5deb..85a15fd49 100644 --- a/openslides/urls.py +++ b/openslides/urls.py @@ -10,26 +10,25 @@ :license: GNU GPL, see LICENSE for more details. """ -from django.conf.urls.defaults import patterns, url, include from django.conf import settings -from django.utils.importlib import import_module +from django.conf.urls.defaults import patterns, url, include from django.shortcuts import redirect +from django.utils.importlib import import_module from openslides.utils.views import FrontPage handler500 = 'openslides.utils.views.server_error' - urlpatterns = patterns('', # frontpage (r'^$', FrontPage.as_view()), - (r'^agenda/', include('agenda.urls')), - (r'^application/', include('application.urls')), - (r'^assignment/', include('assignment.urls')), - (r'^participant/', include('participant.urls')), - (r'^config/', include('config.urls')), - (r'^projector/', include('projector.urls')), + (r'^agenda/', include('openslides.agenda.urls')), + (r'^application/', include('openslides.application.urls')), + (r'^assignment/', include('openslides.assignment.urls')), + (r'^participant/', include('openslides.participant.urls')), + (r'^config/', include('openslides.config.urls')), + (r'^projector/', include('openslides.projector.urls')), (r'^i18n/', include('django.conf.urls.i18n')), ) @@ -44,7 +43,8 @@ for plugin in settings.INSTALLED_PLUGINS: continue plugin_name = mod.__name__.split('.')[0] - urlpatterns += patterns('', (r'^%s/' % plugin_name, include('%s.urls' % plugin_name))) + urlpatterns += patterns('', (r'^%s/' % plugin_name, include('%s.urls' + % plugin_name))) js_info_dict['packages'].append(plugin_name) @@ -64,7 +64,7 @@ urlpatterns += patterns('', ), url(r'^usersettings/$', - 'participant.views.user_settings', + 'openslides.participant.views.user_settings', name='user_settings', ), diff --git a/openslides/utils/pdf.py b/openslides/utils/pdf.py index 6a1aa1fc8..8dbc727a6 100755 --- a/openslides/utils/pdf.py +++ b/openslides/utils/pdf.py @@ -90,7 +90,7 @@ stylesheet.add(ParagraphStyle( leading=20, ), alias='h3') stylesheet.add(ParagraphStyle( - name 'Heading4', + name='Heading4', parent=stylesheet['Bold'], fontSize=10, leading=20,