Ejemplo n.º 1
0
def paper_submission(request):
    try:
        speaker = request.user.speaker
    except models.Speaker.DoesNotExist:
        speaker = None

    conf = models.Conference.objects.current()

    if not conf.cfp_start or not conf.cfp_end:
        return TemplateResponse(request,
                                "conference/cfp/unkown_cfp_status.html")

    if date.today() < conf.cfp_start:
        return TemplateResponse(request, "conference/cfp/cfp_not_started.html")

    if date.today() > conf.cfp_end:
        return TemplateResponse(request,
                                "conference/cfp/cfp_already_closed.html")

    if speaker:
        proposed = list(
            speaker.talk_set.proposed(conference=settings.CONFERENCE))
    else:
        proposed = []
    if not proposed:
        fc = utils.dotted_import(settings.FORMS['PaperSubmission'])
        form = fc(user=request.user, data=request.POST, files=request.FILES)
    else:
        fc = utils.dotted_import(settings.FORMS['AdditionalPaperSubmission'])
        form = fc(data=request.POST, files=request.FILES)

    if request.method == 'POST':
        if not proposed:
            form = fc(user=request.user,
                      data=request.POST,
                      files=request.FILES)
        else:
            form = fc(data=request.POST, files=request.FILES)

        if form.is_valid():
            if not proposed:
                talk = form.save()
                speaker = request.user.speaker
            else:
                talk = form.save(speaker=speaker)
            messages.info(request, 'Your talk has been submitted, thank you!')
            return redirect(reverse('cfp-thank-you-for-proposal'))
    else:
        if not proposed:
            form = fc(user=request.user)
        else:
            form = fc()

    return render_to_response('conference/paper_submission.html', {
        'speaker': speaker,
        'form': form,
        'proposed_talks': proposed,
    },
                              context_instance=RequestContext(request))
Ejemplo n.º 2
0
def paper_submission(request):
    try:
        speaker = request.user.speaker
    except models.Speaker.DoesNotExist:
        speaker = None

    conf = models.Conference.objects.current()

    # per questa conferenza non è previsto il cfp
    if not conf.cfp_start or not conf.cfp_end:
        raise http.Http404()

    # il cfp è concluso
    if not conf.cfp():
        if settings.CFP_CLOSED:
            return redirect(settings.CFP_CLOSED)
        else:
            raise http.Http404()

    if speaker:
        proposed = list(
            speaker.talk_set.proposed(conference=settings.CONFERENCE))
    else:
        proposed = []
    if not proposed:
        fc = utils.dotted_import(settings.FORMS['PaperSubmission'])
        form = fc(user=request.user, data=request.POST, files=request.FILES)
    else:
        fc = utils.dotted_import(settings.FORMS['AdditionalPaperSubmission'])
        form = fc(data=request.POST, files=request.FILES)

    if request.method == 'POST':
        if not proposed:
            form = fc(user=request.user,
                      data=request.POST,
                      files=request.FILES)
        else:
            form = fc(data=request.POST, files=request.FILES)

        if form.is_valid():
            if not proposed:
                talk = form.save()
                speaker = request.user.speaker
            else:
                talk = form.save(speaker=speaker)
            messages.info(request, 'Your talk has been submitted, thank you!')
            return HttpResponseRedirectSeeOther(
                reverse('conference-myself-profile'))
    else:
        if not proposed:
            form = fc(user=request.user)
        else:
            form = fc()
    return render_to_response('conference/paper_submission.html', {
        'speaker': speaker,
        'form': form,
        'proposed_talks': proposed,
    },
                              context_instance=RequestContext(request))
Ejemplo n.º 3
0
def paper_submission(request):
    try:
        speaker = request.user.speaker
    except models.Speaker.DoesNotExist:
        speaker = None

    conf = models.Conference.objects.current()

    # per questa conferenza non è previsto il cfp
    if not conf.cfp_start or not conf.cfp_end:
        raise http.Http404()

    # il cfp è concluso
    if not conf.cfp():
        if settings.CFP_CLOSED:
            return redirect(settings.CFP_CLOSED)
        else:
            raise http.Http404()

    if speaker:
        proposed = list(speaker.talk_set.proposed(conference=settings.CONFERENCE))
    else:
        proposed = []
    if not proposed:
        fc = utils.dotted_import(settings.FORMS['PaperSubmission'])
        form = fc(user=request.user, data=request.POST, files=request.FILES)
    else:
        fc = utils.dotted_import(settings.FORMS['AdditionalPaperSubmission'])
        form = fc(data=request.POST, files=request.FILES)

    if request.method == 'POST':
        if not proposed:
            form = fc(user=request.user, data=request.POST, files=request.FILES)
        else:
            form = fc(data=request.POST, files=request.FILES)

        if form.is_valid():
            if not proposed:
                talk = form.save()
                speaker = request.user.speaker
            else:
                talk = form.save(speaker=speaker)
            messages.info(request, 'Your talk has been submitted, thank you!')
            return HttpResponseRedirectSeeOther(reverse('conference-myself-profile'))
    else:
        if not proposed:
            form = fc(user=request.user)
        else:
            form = fc()
    return render_to_response('conference/paper_submission.html', {
        'speaker': speaker,
        'form': form,
        'proposed_talks': proposed,
    }, context_instance=RequestContext(request))
Ejemplo n.º 4
0
def schedule_event_booking(request, conference, slug, eid):
    evt = get_object_or_404(models.Event, schedule__conference=conference, schedule__slug=slug, id=eid)
    status = models.EventBooking.objects.booking_status(evt.id)
    if request.method == 'POST':
        fc = utils.dotted_import(settings.FORMS['EventBooking'])
        form = fc(event=evt.id, user=request.user.id, data=request.POST)
        if form.is_valid():
            if form.cleaned_data['value']:
                models.EventBooking.objects.book_event(evt.id, request.user.id)
                if request.user.id not in status['booked']:
                    status['booked'].append(request.user.id)
            else:
                models.EventBooking.objects.cancel_reservation(evt.id, request.user.id)
                try:
                    status['booked'].remove(request.user.id)
                except ValueError:
                    pass
        else:
            try:
                msg = unicode(form.errors['value'][0])
            except:
                msg = ""
            return http.HttpResponseBadRequest(msg)
    return {
        'booked': len(status['booked']),
        'available': max(status['available'], 0),
        'seats': status['seats'],
        'user': request.user.id in status['booked'],
    }
Ejemplo n.º 5
0
def get_form(context, name, bound="auto", bound_field=None):
    if '.' in name:
        from conference.utils import dotted_import
        fc = dotted_import(name)
    else:
        fc = getattr(p3forms, name)
    request = context['request']
    if bound:
        if bound == 'auto':
            bound = request.method
        if bound == 'GET':
            data = request.GET
        elif bound == 'POST':
            data = request.POST
        else:
            from django.db.models import Model
            if isinstance(bound, Model):
                data = {}
                for name in fc.base_fields:
                    data[name] = getattr(bound, name)
            else:
                data = bound
        if bound_field and bound_field not in data:
            data = None
    else:
        data = None
    form = fc(data=data)
    if data:
        form.is_valid()
    return form
Ejemplo n.º 6
0
def get_form(context, name, bound="auto", bound_field=None):
    if '.' in name:
        from conference.utils import dotted_import
        fc = dotted_import(name)
    else:
        fc = getattr(p3forms, name)
    request = context['request']
    if bound:
        if bound == 'auto':
            bound = request.method
        if bound == 'GET':
            data = request.GET
        elif bound == 'POST':
            data = request.POST
        else:
            from django.db.models import Model
            if isinstance(bound, Model):
                data = {}
                for name in fc.base_fields:
                    data[name] = getattr(bound, name)
            else:
                data = bound
        if bound_field and bound_field not in data:
            data = None
    else:
        data = None
    form = fc(data=data)
    if data:
        form.is_valid()
    return form
Ejemplo n.º 7
0
def schedule_event_booking(request, conference, slug, eid):
    evt = get_object_or_404(models.Event,
                            schedule__conference=conference,
                            schedule__slug=slug,
                            id=eid)
    status = models.EventBooking.objects.booking_status(evt.id)
    if request.method == 'POST':
        fc = utils.dotted_import(settings.FORMS['EventBooking'])
        form = fc(event=evt.id, user=request.user.id, data=request.POST)
        if form.is_valid():
            if form.cleaned_data['value']:
                models.EventBooking.objects.book_event(evt.id, request.user.id)
                if request.user.id not in status['booked']:
                    status['booked'].append(request.user.id)
            else:
                models.EventBooking.objects.cancel_reservation(
                    evt.id, request.user.id)
                try:
                    status['booked'].remove(request.user.id)
                except ValueError:
                    pass
        else:
            try:
                msg = unicode(form.errors['value'][0])
            except:
                msg = ""
            return http.HttpResponseBadRequest(msg)
    return {
        'booked': len(status['booked']),
        'available': max(status['available'], 0),
        'seats': status['seats'],
        'user': request.user.id in status['booked'],
    }
Ejemplo n.º 8
0
def talk(request, slug, talk, full_access, talk_form=None):
    conf = models.Conference.objects.current()
    if talk_form is None:
        talk_form = utils.dotted_import(settings.FORMS["AdditionalPaperSubmission"])
    if request.method == "POST":
        if not full_access:
            return http.HttpResponseBadRequest()
        if conf.cfp():
            data = request.POST
        else:
            data = request.POST.copy()
            data["level"] = talk.level
            data["duration"] = talk.duration
            data["qa_duration"] = talk.qa_duration
            data["language"] = talk.language
            data["type"] = talk.type
            data["tags"] = ",".join([x.name for x in talk.tags.all()])
        form = talk_form(data=data, files=request.FILES, instance=talk)
        if not conf.cfp() and not data["tags"] and "tags" in form.fields:
            # Il CFP e' chiuso e stiamo editando un talk senza tags, la cosa
            # non e' normalmente possibile visto che i tags sono richiesti;
            # stiamo probabilmente editando un talk inserito tramite admin, se
            # questo e' il caso non ha senso far fallire la validazione della
            # form.
            form.fields["tags"].required = False
        if form.is_valid():
            talk = form.save()
            messages.info(request, "Your talk has been modified.")
            return HttpResponseRedirectSeeOther(reverse("conference-talk", kwargs={"slug": talk.slug}))
    else:
        form = talk_form(instance=talk)
    return {"form": form, "full_access": full_access, "talk": talk, "cfp": conf.cfp(), "voting": conf.voting()}
Ejemplo n.º 9
0
 def available_stats(self, conf):
     stats = []
     for path in settings.ADMIN_ATTENDEE_STATS:
         func = utils.dotted_import(path)
         w = {
             'get_data': self._stat_wrapper(func, conf),
             'short_description': getattr(func, 'short_description', func.__name__.replace('_', ' ').strip()),
             'description': getattr(func, 'description', func.__doc__),
         }
         stats.append(w)
     return stats
Ejemplo n.º 10
0
 def available_stats(self, conf):
     stats = []
     for path in settings.ADMIN_ATTENDEE_STATS:
         func = utils.dotted_import(path)
         w = {
             'get_data':
             self._stat_wrapper(func, conf),
             'short_description':
             getattr(func, 'short_description',
                     func.__name__.replace('_', ' ').strip()),
             'description':
             getattr(func, 'description', func.__doc__),
         }
         stats.append(w)
     return stats
Ejemplo n.º 11
0
def user_profile(request, slug, profile=None, full_access=False):
    fc = utils.dotted_import(settings.FORMS["Profile"])
    if request.method == "POST":
        if not full_access:
            return http.HttpResponseForbidden()
        form = fc(instance=profile, data=request.POST, files=request.FILES)
        if form.is_valid():
            form.save()
            return HttpResponseRedirectSeeOther(reverse("conference-profile", kwargs={"slug": profile.slug}))
    else:
        if full_access:
            form = fc(instance=profile)
        else:
            form = None
    return {"form": form, "full_access": full_access, "profile": profile}
Ejemplo n.º 12
0
def user_profile(request, slug, profile=None, full_access=False):
    fc = utils.dotted_import(settings.FORMS['Profile'])
    if request.method == 'POST':
        if not full_access:
            return http.HttpResponseForbidden()
        form = fc(instance=profile, data=request.POST, files=request.FILES)
        if form.is_valid():
            form.save()
            return HttpResponseRedirectSeeOther(reverse('conference-profile', kwargs={'slug': profile.slug}))
    else:
        if full_access:
            form = fc(instance=profile)
        else:
            form = None
    return {
        'form': form,
        'full_access': full_access,
        'profile': profile,
    }
Ejemplo n.º 13
0
def user_profile(request, slug, profile=None, full_access=False):
    fc = utils.dotted_import(settings.FORMS['Profile'])
    if request.method == 'POST':
        if not full_access:
            return http.HttpResponseForbidden()
        form = fc(instance=profile, data=request.POST, files=request.FILES)
        if form.is_valid():
            form.save()
            return HttpResponseRedirectSeeOther(
                reverse('conference-profile', kwargs={'slug': profile.slug}))
    else:
        if full_access:
            form = fc(instance=profile)
        else:
            form = None
    return {
        'form': form,
        'full_access': full_access,
        'profile': profile,
    }
Ejemplo n.º 14
0
def talk(request, slug, talk, full_access, talk_form=None):
    conf = models.Conference.objects.current()
    if talk_form is None:
        talk_form = utils.dotted_import(
            settings.FORMS['AdditionalPaperSubmission'])
    if request.method == 'POST':
        if not full_access:
            return http.HttpResponseBadRequest()
        if conf.cfp():
            data = request.POST
        else:
            data = request.POST.copy()
            data['level'] = talk.level
            data['duration'] = talk.duration
            data['qa_duration'] = talk.qa_duration
            data['language'] = talk.language
            data['type'] = talk.type
            data['tags'] = ','.join([x.name for x in talk.tags.all()])
        form = talk_form(data=data, files=request.FILES, instance=talk)
        if not conf.cfp() and not data['tags'] and 'tags' in form.fields:
            # Il CFP e' chiuso e stiamo editando un talk senza tags, la cosa
            # non e' normalmente possibile visto che i tags sono richiesti;
            # stiamo probabilmente editando un talk inserito tramite admin, se
            # questo e' il caso non ha senso far fallire la validazione della
            # form.
            form.fields['tags'].required = False
        if form.is_valid():
            talk = form.save()
            messages.info(request, 'Your talk has been modified.')
            return HttpResponseRedirectSeeOther(
                reverse('conference-talk', kwargs={'slug': talk.slug}))
    else:
        form = talk_form(instance=talk)
    return {
        'form': form,
        'full_access': full_access,
        'talk': talk,
        'cfp': conf.cfp(),
        'voting': conf.voting(),
    }
Ejemplo n.º 15
0
def talk(request, slug, talk, full_access, talk_form=None):
    conf = models.Conference.objects.current()
    if talk_form is None:
        talk_form = utils.dotted_import(settings.FORMS['AdditionalPaperSubmission'])
    if request.method == 'POST':
        if not full_access:
            return http.HttpResponseBadRequest()
        if conf.cfp():
            data = request.POST
        else:
            data = request.POST.copy()
            data['level'] = talk.level
            data['duration'] = talk.duration
            data['qa_duration'] = talk.qa_duration
            data['language'] = talk.language
            data['type'] = talk.type
            data['tags'] = ','.join([ x.name for x in talk.tags.all() ])
        form = talk_form(data=data, files=request.FILES, instance=talk)
        if not conf.cfp() and not data['tags'] and 'tags' in form.fields:
            # Il CFP e' chiuso e stiamo editando un talk senza tags, la cosa
            # non e' normalmente possibile visto che i tags sono richiesti;
            # stiamo probabilmente editando un talk inserito tramite admin, se
            # questo e' il caso non ha senso far fallire la validazione della
            # form.
            form.fields['tags'].required = False
        if form.is_valid():
            talk = form.save()
            messages.info(request, 'Your talk has been modified.')
            return HttpResponseRedirectSeeOther(reverse('conference-talk', kwargs={'slug': talk.slug}))
    else:
        form = talk_form(instance=talk)
    return {
        'form': form,
        'full_access': full_access,
        'talk': talk,
        'cfp': conf.cfp(),
        'voting': conf.voting(),
    }
Ejemplo n.º 16
0
def talk(request, slug, talk, full_access, talk_form=None):
    conf = models.Conference.objects.current()
    if talk_form is None:
        talk_form = utils.dotted_import(
            settings.FORMS['AdditionalPaperSubmission'])
    if request.method == 'POST':
        if not full_access:
            return http.HttpResponseBadRequest()
        if conf.cfp():
            data = request.POST
        else:
            data = request.POST.copy()
            data['level'] = talk.level
            data['duration'] = talk.duration
            data['language'] = talk.language
            data['type'] = talk.type
            data['tags'] = ','.join([x.name for x in talk.tags.all()])
        form = talk_form(data=data, files=request.FILES, instance=talk)
        if not conf.cfp() and not data['tags'] and 'tags' in form.fields:
            # The CFP and 'closed and we are editing a talk without tags,
            # it is not' normally possible since the tags are required;
            # we're probably editing a talk inserted through admin, and if that
            # 's the case does not make sense to derail the form validation.
            form.fields['tags'].required = False
        if form.is_valid():
            talk = form.save()
            messages.info(request, 'Your talk has been modified.')
            return HttpResponseRedirectSeeOther(
                reverse('conference-talk', kwargs={'slug': talk.slug}))
    else:
        form = talk_form(instance=talk)
    return {
        'form': form,
        'full_access': full_access,
        'talk': talk,
        'cfp': conf.cfp(),
        'voting': conf.voting(),
    }