Beispiel #1
0
def agenda_edit(request, event_id, agenda_id=None, template='con/agenda_edit.html'):
    event = get_object_or_404(Event, pk=event_id)
    agenda = None
    if agenda_id:
        agenda = get_object_or_404(Event, pk=agenda_id)

#    if request.user not in event.user_authors:
#        raise Http403()

    standard_attributes = ['title', 'start', 'end', 'place']

    if request.method == "POST":
        #TODO: Verify that agenda is inside event time
        #TODO: Author might not be user / request.user
        agenda_form = AgendaForm(request.POST)
        if agenda_form.is_valid():
            if request.POST.get('save', None):
                if not agenda:
                    create_event(
                        parent = event,
                        author = request.user,
                        # public = event.is_public
                        **agenda_form.cleaned_data
                    )
                else:
                    for attr in standard_attributes:
                        setattr(agenda, attr, agenda_form.cleaned_data[attr])
                    agenda.djangomarkup_description = agenda_form.cleaned_data['description']
                    agenda.save()

                return HttpResponseRedirect(reverse('con:agenda-edit', kwargs={'event_id' : event.pk}))
            
            elif request.POST.get('delete', None):
                agenda.delete()
                return HttpResponseRedirect(reverse('con:agenda-edit', kwargs={'event_id' : event.pk}))
            
            else:
                return HttpResponseBadRequest("Action name not recognized")

    elif agenda_id:
        agenda_form = AgendaForm(initial={
            'title' : agenda.title,
            'place' : agenda.place,
            'start' : agenda.start.strftime('%Y-%m-%d %H:%M'),
            'end' : agenda.end.strftime('%Y-%m-%d %H:%M'),
            'description' : agenda.djangomarkup_description
        })
    else:
        agenda_form = AgendaForm()

    return render_to_response(template, {
        'agenda_form' : agenda_form,
        'event' : event,
        'agenda' : agenda,
        'agendas' : event.get_structured_agenda()
    }, context_instance=RequestContext(request))
Beispiel #2
0
    def setUp(self):
        super(TestAgenda, self).setUp()
        self.user = create_user(u"Andrej Tokarčík", "xxx", "*****@*****.**")
        self.holger = create_user(u"Holger", "xxx", "*****@*****.**")

        self.now = datetime.now()

        self.event = create_event(
            title = u"PragoCon",
            start = self.now,
            end = self.now + timedelta(hours=1),
            description = u'''
= Cool event =

Sluníčkový event s unicodem.

""Frikulínskej"", as in """角色扮演游戏""".
''',
            is_public = True,
            facebook_publish = False,
            author = self.user
        )

        self.agenda_one = create_event(
            title = u"Úvod do Poezie",
            start = self.now,
            end = self.now + timedelta(hours=1),
            description = u'''
= Úvod do poezie =

S Olgou. Bude tam hodně znaků.
''',
            is_public = True,
            facebook_publish = False,
            author = self.holger,
            parent = self.event,
            place = u'Místnost 1'
        )
Beispiel #3
0
def new(request, template='con/new.html'):
    if request.method == "POST":
        event_form = EventForm(request.POST)
        if event_form.is_valid():
            event = create_event(author=request.user, **event_form.cleaned_data)
            return HttpResponseRedirect(reverse("con:event-profile", kwargs={
                'event_id' : event.pk
            }))

    else:
        event_form = EventForm()
    return render_to_response(template, {
        'event_form' : event_form
    }, context_instance=RequestContext(request))
Beispiel #4
0
    def create_default_event(self):
        self.event = create_event(
            title = u"PragoCon",
            start = self.now,
            end = self.now + timedelta(hours=1),
            description = u'''
= Cool event =

Sluníčkový event s unicodem.

""Frikulínskej"", as in """角色扮演游戏""".
''',
            is_public = True,
            facebook_publish = False,
            author = self.user
        )