コード例 #1
0
ファイル: views.py プロジェクト: piratenmv/openslides
def get_system_config(request):
    if request.method == 'POST':
        form = SystemConfigForm(request.POST)
        if form.is_valid():
            config_set('system_url', form.cleaned_data['system_url'])
            config_set('system_welcometext', form.cleaned_data['system_welcometext'])
            if form.cleaned_data['system_enable_anonymous']:
                config_set('system_enable_anonymous', True)
                # check for Anonymous group and (re)create it as needed
                try:
                    anonymous = Group.objects.get(name='Anonymous')
                except Group.DoesNotExist:
                    default_perms = [u'can_see_agenda', u'can_see_projector', u'can_see_application']
                    anonymous = Group()
                    anonymous.name = 'Anonymous'
                    anonymous.save()
                    anonymous.permissions = Permission.objects.filter(codename__in=default_perms)
                    anonymous.save()
                messages.success(request, _('Anonymous access enabled. Please modify the "Anonymous" group to fit your required permissions.'))
            else:
                # use '' - False will evaluate to uniced(False) => True..
                config_set('system_enable_anonymous', '')
            messages.success(request, _('System settings successfully saved.'))
        else:
            messages.error(request, _('Please check the form for errors.'))
    else:
        form = SystemConfigForm(initial={
            'system_url': config_get('system_url'),
            'system_welcometext': config_get('system_welcometext'),
            'system_enable_anonymous': config_get('system_enable_anonymous'),
        })
    return {
        'form': form,
    }
コード例 #2
0
ファイル: views.py プロジェクト: piratenmv/openslides
def get_group_overview(request):
    if config_get('system_enable_anonymous', False):
        groups = Group.objects.all()
    else:
        groups = Group.objects.exclude(name='Anonymous')
    return {
        'groups': groups,
    }
コード例 #3
0
ファイル: views.py プロジェクト: piratenmv/openslides
def get_assignment_config(request):
    if request.method == 'POST':
        form_assignment = AssignmentConfigForm(request.POST, prefix='assignment')
        if form_assignment.is_valid():
            config_set('assignment_pdf_ballot_papers_selection', form_assignment.cleaned_data['assignment_pdf_ballot_papers_selection'])
            config_set('assignment_pdf_ballot_papers_number', form_assignment.cleaned_data['assignment_pdf_ballot_papers_number'])
            config_set('assignment_pdf_title', form_assignment.cleaned_data['assignment_pdf_title'])
            config_set('assignment_pdf_preamble', form_assignment.cleaned_data['assignment_pdf_preamble'])
            messages.success(request, _('Election settings successfully saved.'))
        else:
            messages.error(request, _('Please check the form for errors.'))
    else:
        form_assignment = AssignmentConfigForm(initial={
            'assignment_pdf_ballot_papers_selection': config_get('assignment_pdf_ballot_papers_selection'),
            'assignment_pdf_ballot_papers_number': config_get('assignment_pdf_ballot_papers_number'),
            'assignment_pdf_title': config_get('assignment_pdf_title'),
            'assignment_pdf_preamble': config_get('assignment_pdf_preamble'),
        }, prefix='assignment')
    return {
        'form_assignment': form_assignment,
    }
コード例 #4
0
ファイル: views.py プロジェクト: piratenmv/openslides
def get_agenda_config(request):
    if request.method == 'POST':
        form_agenda = AgendaConfigForm(request.POST, prefix='agenda')
        if form_agenda.is_valid():
            config_set('agenda_countdown_time', form_agenda.cleaned_data['agenda_countdown_time'])
            messages.success(request, _('Agenda settings successfully saved.'))
        else:
            messages.error(request, _('Please check the form for errors.'))
    else:
        form_agenda = AgendaConfigForm(initial={
            'agenda_countdown_time': config_get('agenda_countdown_time'),
        }, prefix='agenda')
    return {
        'form_agenda': form_agenda,
    }
コード例 #5
0
ファイル: views.py プロジェクト: piratenmv/openslides
def get_general_config(request):
    if request.method == 'POST':
        form_event = EventConfigForm(request.POST, prefix='event')
        if form_event.is_valid():
            # event form
            config_set('event_name', form_event.cleaned_data['event_name'])
            config_set('event_description', form_event.cleaned_data['event_description'])
            config_set('event_date', form_event.cleaned_data['event_date'])
            config_set('event_location', form_event.cleaned_data['event_location'])
            config_set('event_organizer', form_event.cleaned_data['event_organizer'])
            messages.success(request, _('General settings successfully saved.'))
        else:
            messages.error(request, _('Please check the form for errors.'))
    else:
        form_event = EventConfigForm(initial={
            'event_name': config_get('event_name'),
        }, prefix='event')
    return {
        'form_event': form_event,
    }
コード例 #6
0
ファイル: tags.py プロジェクト: piratenmv/openslides
def get_min_supporters():
    return config_get('application_min_supporters')
コード例 #7
0
ファイル: tags.py プロジェクト: piratenmv/openslides
def get_config(key):
    return config_get(key)