Beispiel #1
0
def swap(request, slotid):
    oldslot = Slot.objects.get(id=slotid)
    if not topiclead(request.user, oldslot.topic):
        return HttpResponseForbidden("Forbidden")
    if request.method == 'POST':
        newslotid = int(request.POST['newslotid'])
        newslot = Slot.objects.get(id=newslotid, topic=oldslot.topic)
        new_start_time = newslot.start_time
        new_room = newslot.room
        newslot.start_time = oldslot.start_time
        newslot.room = oldslot.room
        oldslot.start_time = new_start_time
        oldslot.room = new_room
        newslot.save()
        oldslot.save()
        return HttpResponseRedirect('/scheduling/%s' % oldslot.topic.id)

    newslots = []
    available_slots = Slot.objects.filter(
                          topic=oldslot.topic).exclude(id=slotid)
    for slot in available_slots:
        triplet = (slot.start_time, slot.id, combined_title(slot))
        newslots.append(triplet)
    return render(request, 'slotswap.html',
                  {'title': combined_title(oldslot),
                   'oldslot': oldslot,
                   'newslots': newslots})
Beispiel #2
0
def publish(request, topicid):
    topic = Topic.objects.get(id=topicid)
    if not topiclead(request.user, topic):
        return HttpResponseForbidden("Forbidden")
    list_calls = ""
    baseurl = "http://%s.sched.org/api/session/" % settings.SCHED_URL
    for slot in Slot.objects.filter(topic=topicid):
        if len(slot.proposals.all()) > 0:
            values = {'api_key': settings.SCHED_API_KEY,
                      'session_key': "slot-%d" % combined_id(slot),
                      'name': smart_str(combined_title(slot)),
                      'session_start': slot.start_time,
                      'session_end': end_time(slot.start_time),
                      'session_type': 'Design Summit',
                      'session_subtype': slot.topic,
                      'venue': slot.room.name,
                      'description': htmlize(smart_str(
                                              full_description(slot)))}
            data = urllib.urlencode(values)
            if settings.SCHED_API_KEY == "getThisFromSched":
                list_calls += "%s<P>" % data
            else:
                f = urllib2.urlopen(baseurl + "mod", data)
                if f.readline().startswith("ERR:"):
                    f.close()
                    f = urllib2.urlopen(baseurl + "add", data)
                    f.close()
    return render(request, "sched.html",
                  {'list_calls': list_calls,
                   'topic': topic})
Beispiel #3
0
def edit(request, slotid):
    slot = Slot.objects.get(id=slotid)
    if not topiclead(request.user, slot.topic):
        return HttpResponseForbidden("Forbidden")
    if request.method == 'POST':
        form = SlotForm(request.POST, instance=slot)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/scheduling/%s' % slot.topic.id)
    else:
        form = SlotForm(instance=slot)
    return render(request, 'slotedit.html',
                  {'form': form,
                   'title': combined_title(slot),
                   'full_desc': combined_description(slot),
                   'slot': slot})