def set_elected(request, assignment_id, user_id, elected=True): assignment = Assignment.objects.get(pk=assignment_id) person = get_person(user_id) assignment.set_elected(person, elected) if request.is_ajax(): if elected: link = reverse('assignment_user_not_elected', args=[assignment.id, person.person_id]) text = _('not elected') else: link = reverse('assignment_user_elected', args=[assignment.id, person.person_id]) text = _('elected') return ajax_request({'elected': elected, 'link': link, 'text': text}) return redirect(reverse('assignment_view', args=[assignment_id]))
def beamer_edit(request, direction): if direction == 'bigger': config_set('bigger', int(config_get('bigger', 100)) + 10) elif direction == 'smaller': config_set('bigger', int(config_get('bigger', 100)) - 10) elif direction == 'up': config_set('up', int(config_get('up', 0)) - 10) elif direction == 'down': config_set('up', int(config_get('up', 0)) + 10) elif direction == 'clean': config_set('up', 0) config_set('bigger', 100) if request.is_ajax(): return ajax_request({}) return redirect(reverse('item_overview'))
def set_active(request, item_id, summary=False): """ Set an Item as the active one. """ if item_id == "0": config_set("presentation", "0") else: try: item = Item.objects.get(id=item_id) item.set_active(summary) except Item.DoesNotExist: messages.error(request, _('Item ID %d does not exist.') % int(item_id)) config_set("bigger", 100) config_set("up", 0) if request.is_ajax(): return ajax_request({'active': item_id}) return redirect(reverse('item_overview'))
def beamerhome(request): """ Shows a active Slide. """ data = {'ajax': 'on'} template = '' try: item = get_active_item() votes = assignment_votes(item) polls = assignment_polls(item) if is_summary(): items = item.children.filter(hidden=False) data['items'] = items data['title'] = item.title template = 'beamer/overview.html' else: data['item'] = item.cast() data['title'] = item.title data['votes'] = votes data['polls'] = polls template = 'beamer/%shome.html' % (item.type) except Item.DoesNotExist: items = Item.objects.filter(parent=None).filter(hidden=False)\ .order_by('weight') data['items'] = items data['title'] = _("Agenda") template = 'beamer/overview.html' if request.is_ajax(): content = render_block_to_string(template, 'content', data) jsondata = {'content': content, 'title': data['title'], 'time': datetime.now().strftime('%H:%M'), 'bigger': config_get('bigger'), 'up': config_get('up'), 'countdown_visible': config_get('countdown_visible'), 'countdown_time': config_get('agenda_countdown_time'), 'countdown_control': config_get('countdown_control'), } return ajax_request(jsondata) else: return render_to_response(template, data, context_instance=RequestContext(request))
def set_closed(request, item_id, closed=True): """ Close or open an Item. """ try: item = Item.objects.get(id=item_id) item.set_closed(closed) except Item.DoesNotExist: messages.error(request, _('Item ID %d does not exist.') % int(item_id)) if request.is_ajax(): if closed: link = reverse('item_open', args=[item.id]) else: link = reverse('item_close', args=[item.id]) return ajax_request({'closed': closed, 'link': link}) return redirect(reverse('item_overview'))
def set_publish_status(request, poll_id): try: poll = AssignmentPoll.objects.get(pk=poll_id) if poll.published: poll.set_published(False) else: poll.set_published(True) except AssignmentPoll.DoesNotExist: messages.error(request, _('Ballot ID %d does not exist.') % int(poll_id)) return redirect(reverse('assignment_overview')) if request.is_ajax(): return ajax_request({'published': poll.published}) if poll.published: messages.success(request, _("Ballot successfully published.")) else: messages.success(request, _("Ballot successfully unpublished.")) return redirect(reverse('assignment_view', args=[poll.assignment.id]))
def beamer_countdown(request, command, time=60): if command == 'show': config_set('countdown_visible', True) elif command == 'hide': config_set('countdown_visible', False) elif command == 'reset': config_set('countdown_control', 'reset') elif command == 'start': config_set('countdown_control', 'start') elif command == 'stop': config_set('countdown_control', 'stop') if request.is_ajax(): if command == "show": link = reverse('countdown_close') else: link = reverse('countdown_open') return ajax_request({'countdown_visible': config_get('countdown_visible'), 'link': link}) return redirect(reverse('item_overview'))