cleanup openslides base files.

Do not manipulate the pythonpath anymore.
This commit is contained in:
Oskar Hahn 2012-07-10 14:00:51 +02:00
parent 5fcef8aba4
commit aa130ab2da
17 changed files with 70 additions and 73 deletions

View File

@ -55,7 +55,6 @@ def hg_version():
try: try:
ui = hgui.ui() ui = hgui.ui()
repository = localrepository(ui, join(conts, '..')) repository = localrepository(ui, join(conts, '..'))
#repository = localrepository(ui, conts)
ctx = repository['.'] ctx = repository['.']
if ctx.tags() and ctx.tags() != ['tip']: if ctx.tags() and ctx.tags() != ['tip']:
version = ' '.join(ctx.tags()) version = ' '.join(ctx.tags())
@ -77,7 +76,7 @@ def hg_version():
return version return version
import os, site ## import os, site
##
SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) ## SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
site.addsitedir(SITE_ROOT) ## site.addsitedir(SITE_ROOT)

View File

@ -104,23 +104,12 @@ class Item(MPTTModel, SlideMixin):
self.closed = closed self.closed = closed
self.save() 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 @property
def weight_form(self): def weight_form(self):
""" """
Return the WeightForm for this item. Return the WeightForm for this item.
""" """
from agenda.forms import ItemOrderForm from openslides.agenda.forms import ItemOrderForm
try: try:
parent = self.parent.id parent = self.parent.id
except AttributeError: except AttributeError:

View File

@ -11,8 +11,8 @@
""" """
from django.conf.urls.defaults import url, patterns from django.conf.urls.defaults import url, patterns
from agenda.views import (Overview, View, SetClosed, ItemUpdate, ItemCreate, from openslides.agenda.views import (Overview, View, SetClosed, ItemUpdate,
ItemDelete, AgendaPDF) ItemCreate, ItemDelete, AgendaPDF)
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'^$', url(r'^$',

View File

@ -12,10 +12,10 @@
from django.conf.urls.defaults import url, patterns from django.conf.urls.defaults import url, patterns
from application.views import (ApplicationDelete, ViewPoll, ApplicationPDF, from openslides.application.views import (ApplicationDelete, ViewPoll,
ApplicationPollPDF, CreateAgendaItem) ApplicationPDF, ApplicationPollPDF, CreateAgendaItem)
urlpatterns = patterns('application.views', urlpatterns = patterns('openslides.application.views',
url(r'^$', url(r'^$',
'overview', 'overview',
name='application_overview', name='application_overview',

View File

@ -13,10 +13,10 @@
from django import forms from django import forms
from django.utils.translation import ugettext_lazy as _, ugettext_noop 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 openslides.participant.models import Profile
from assignment.models import Assignment from openslides.assignment.models import Assignment
class AssignmentForm(forms.ModelForm, CssClassMixin): class AssignmentForm(forms.ModelForm, CssClassMixin):

View File

@ -26,7 +26,7 @@ from openslides.participant.models import Profile
from openslides.poll.models import (BasePoll, CountInvalid, CountVotesCast, from openslides.poll.models import (BasePoll, CountInvalid, CountVotesCast,
BaseOption, PublishPollMixin) BaseOption, PublishPollMixin)
from agenda.models import Item from openslides.agenda.models import Item
class Assignment(models.Model, SlideMixin): class Assignment(models.Model, SlideMixin):

View File

@ -12,10 +12,10 @@
from django.conf.urls.defaults import url, patterns from django.conf.urls.defaults import url, patterns
from assignment.views import (ViewPoll, AssignmentPDF, AssignmentPollPDF, from openslides.assignment.views import (ViewPoll, AssignmentPDF,
AssignmentPollDelete, CreateAgendaItem) AssignmentPollPDF, AssignmentPollDelete, CreateAgendaItem)
urlpatterns = patterns('assignment.views', urlpatterns = patterns('openslides.assignment.views',
url(r'^$', url(r'^$',
'get_overview', 'get_overview',
name='assignment_overview', name='assignment_overview',

View File

@ -25,11 +25,11 @@ from django.contrib.auth.models import User
from django.shortcuts import redirect from django.shortcuts import redirect
from django.utils.translation import ungettext, ugettext as _ from django.utils.translation import ungettext, ugettext as _
from utils.pdf import stylesheet from openslides.utils.pdf import stylesheet
from utils.template import Tab from openslides.utils.template import Tab
from utils.utils import (template, permission_required, gen_confirm_form, from openslides.utils.utils import (template, permission_required,
del_confirm_form, ajax_request) gen_confirm_form, del_confirm_form, ajax_request)
from utils.views import FormView, DeleteView, PDFView, RedirectView from openslides.utils.views import FormView, DeleteView, PDFView, RedirectView
from openslides.config.models import config from openslides.config.models import config
from openslides.participant.models import Profile from openslides.participant.models import Profile

View File

@ -116,7 +116,8 @@ def set_submenu(sender, request, context, **kwargs):
except (ImportError, AttributeError): except (ImportError, AttributeError):
continue continue
appname = mod.__name__.split('.')[0] appname = mod.__name__.split('.')[-1]
selected = reverse('config_%s' % appname) == request.path selected = reverse('config_%s' % appname) == request.path
try: try:
title = mod.NAME title = mod.NAME

View File

@ -33,7 +33,7 @@ for app in settings.INSTALLED_APPS:
mod = import_module(app + '.views') mod = import_module(app + '.views')
except ImportError: except ImportError:
continue continue
appname = mod.__name__.split('.')[0] appname = mod.__name__.split('.')[-2]
try: try:
urlpatterns += patterns('', url( urlpatterns += patterns('', url(
r'^%s/$' % appname, r'^%s/$' % appname,

View File

@ -10,6 +10,7 @@
:license: GNU GPL, see LICENSE for more details. :license: GNU GPL, see LICENSE for more details.
""" """
# for python 2.5 support
from __future__ import with_statement from __future__ import with_statement
import os import os
@ -72,6 +73,7 @@ def main(argv = None):
start_browser(url) start_browser(url)
execute_from_command_line(argv) execute_from_command_line(argv)
def detect_listen_opts(address, port): def detect_listen_opts(address, port):
if address is None: if address is None:
try: try:
@ -93,6 +95,7 @@ def detect_listen_opts(address, port):
return address, port return address, port
def start_browser(url): def start_browser(url):
browser = webbrowser.get() browser = webbrowser.get()
def f(): def f():
@ -102,6 +105,7 @@ def start_browser(url):
t = threading.Thread(target = f) t = threading.Thread(target = f)
t.start() t.start()
def prepare_openslides(url, always_syncdb = False): def prepare_openslides(url, always_syncdb = False):
settings_module = os.environ.get(django.conf.ENVIRONMENT_VARIABLE) settings_module = os.environ.get(django.conf.ENVIRONMENT_VARIABLE)
if not settings_module: if not settings_module:
@ -140,6 +144,7 @@ def prepare_openslides(url, always_syncdb = False):
create_or_reset_admin_user() create_or_reset_admin_user()
return True return True
def run_syncdb(url): def run_syncdb(url):
# now initialize the database # now initialize the database
argv = ["", "syncdb", "--noinput"] argv = ["", "syncdb", "--noinput"]
@ -147,6 +152,7 @@ def run_syncdb(url):
set_system_url(url) set_system_url(url)
def check_database(url): def check_database(url):
"""Detect if database was deleted and recreate if necessary""" """Detect if database was deleted and recreate if necessary"""
# can't be imported in global scope as they already require # can't be imported in global scope as they already require
@ -162,6 +168,7 @@ def check_database(url):
return True return True
return False return False
def create_or_reset_admin_user(): def create_or_reset_admin_user():
# can't be imported in global scope as it already requires # can't be imported in global scope as it already requires
# the settings module during import # the settings module during import
@ -180,6 +187,7 @@ def create_or_reset_admin_user():
obj.set_password("admin") obj.set_password("admin")
obj.save() obj.save()
def set_system_url(url): def set_system_url(url):
# can't be imported in global scope as it already requires # can't be imported in global scope as it already requires
# the settings module during import # the settings module during import
@ -196,5 +204,6 @@ def generate_secret_key():
chars = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)" chars = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)"
return get_random_string(50, chars) return get_random_string(50, chars)
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -12,7 +12,6 @@
import os import os
import sys import sys
from django.conf.global_settings import *
_fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() _fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
def _fs2unicode(s): def _fs2unicode(s):
@ -21,11 +20,10 @@ def _fs2unicode(s):
return s.decode(_fs_encoding) return s.decode(_fs_encoding)
SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
#SITE_ROOT = os.path.join(SITE_ROOT, '..')
AUTH_PROFILE_MODULE = 'participant.Profile' 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_URL = '/login/'
LOGIN_REDIRECT_URL = '/' LOGIN_REDIRECT_URL = '/'
@ -34,16 +32,15 @@ DBPATH = _fs2unicode(os.path.join(os.path.join(SITE_ROOT, '..'), 'database.db'))
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'ENGINE': 'django.db.backends.sqlite3',
'NAME': DBPATH, # Or path to database file if using sqlite3. 'NAME': DBPATH,
'USER': '', # Not used with sqlite3. 'USER': '',
'PASSWORD': '', # Not used with sqlite3. 'PASSWORD': '',
'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'HOST': '',
'PORT': '', # Set to empty string for default. Not used with sqlite3. 'PORT': '',
} }
} }
ugettext = lambda s: s ugettext = lambda s: s
LANGUAGES = ( LANGUAGES = (
@ -111,7 +108,8 @@ MIDDLEWARE_CLASSES = (
ROOT_URLCONF = 'openslides.urls' ROOT_URLCONF = 'openslides.urls'
TEMPLATE_DIRS = ( 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. # Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths. # Don't forget to use absolute paths, not relative paths.
_fs2unicode(os.path.join(SITE_ROOT, 'templates')), _fs2unicode(os.path.join(SITE_ROOT, 'templates')),
@ -124,14 +122,14 @@ INSTALLED_APPS = (
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'mptt', 'mptt',
'utils', 'openslides.utils',
'poll', 'openslides.poll',
'projector', 'openslides.projector',
'agenda', 'openslides.agenda',
'application', 'openslides.application',
'assignment', 'openslides.assignment',
'participant', 'openslides.participant',
'config', 'openslides.config',
) )
TEMPLATE_CONTEXT_PROCESSORS = ( TEMPLATE_CONTEXT_PROCESSORS = (
@ -140,6 +138,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request', 'django.core.context_processors.request',
'django.core.context_processors.i18n', 'django.core.context_processors.i18n',
'django.core.context_processors.static', 'django.core.context_processors.static',
'utils.utils.revision', 'openslides.utils.utils.revision',
'openslides.utils.auth.anonymous_context_additions', 'openslides.utils.auth.anonymous_context_additions',
) )

View File

@ -13,9 +13,10 @@
from django.conf.urls.defaults import url, patterns from django.conf.urls.defaults import url, patterns
from django.core.urlresolvers import reverse 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'^$', url(r'^$',
'get_overview', 'get_overview',
name='user_overview', name='user_overview',

View File

@ -160,7 +160,7 @@ class BasePoll(models.Model):
""" """
Return the form for one option of the poll. 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']), return OptionForm(extra=self.get_form_values(kwargs['formid']),
**kwargs) **kwargs)

View File

@ -17,7 +17,7 @@ from openslides.projector.views import (ControlView, ActivateView,
CountdownEdit, ProjectorEdit, Projector, ActivateOverlay) CountdownEdit, ProjectorEdit, Projector, ActivateOverlay)
urlpatterns = patterns('projector.views', urlpatterns = patterns('',
url(r'^$', url(r'^$',
Projector.as_view(), Projector.as_view(),
{'sid': None}, {'sid': None},

View File

@ -10,26 +10,25 @@
:license: GNU GPL, see LICENSE for more details. :license: GNU GPL, see LICENSE for more details.
""" """
from django.conf.urls.defaults import patterns, url, include
from django.conf import settings 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.shortcuts import redirect
from django.utils.importlib import import_module
from openslides.utils.views import FrontPage from openslides.utils.views import FrontPage
handler500 = 'openslides.utils.views.server_error' handler500 = 'openslides.utils.views.server_error'
urlpatterns = patterns('', urlpatterns = patterns('',
# frontpage # frontpage
(r'^$', FrontPage.as_view()), (r'^$', FrontPage.as_view()),
(r'^agenda/', include('agenda.urls')), (r'^agenda/', include('openslides.agenda.urls')),
(r'^application/', include('application.urls')), (r'^application/', include('openslides.application.urls')),
(r'^assignment/', include('assignment.urls')), (r'^assignment/', include('openslides.assignment.urls')),
(r'^participant/', include('participant.urls')), (r'^participant/', include('openslides.participant.urls')),
(r'^config/', include('config.urls')), (r'^config/', include('openslides.config.urls')),
(r'^projector/', include('projector.urls')), (r'^projector/', include('openslides.projector.urls')),
(r'^i18n/', include('django.conf.urls.i18n')), (r'^i18n/', include('django.conf.urls.i18n')),
) )
@ -44,7 +43,8 @@ for plugin in settings.INSTALLED_PLUGINS:
continue continue
plugin_name = mod.__name__.split('.')[0] 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) js_info_dict['packages'].append(plugin_name)
@ -64,7 +64,7 @@ urlpatterns += patterns('',
), ),
url(r'^usersettings/$', url(r'^usersettings/$',
'participant.views.user_settings', 'openslides.participant.views.user_settings',
name='user_settings', name='user_settings',
), ),

View File

@ -90,7 +90,7 @@ stylesheet.add(ParagraphStyle(
leading=20, leading=20,
), alias='h3') ), alias='h3')
stylesheet.add(ParagraphStyle( stylesheet.add(ParagraphStyle(
name 'Heading4', name='Heading4',
parent=stylesheet['Bold'], parent=stylesheet['Bold'],
fontSize=10, fontSize=10,
leading=20, leading=20,