def clone_event(request):
    if not request.POST:
        return HttpResponseForbidden()
    event = Event.objects.get(pk=request.POST["existing_event"])
    new_event = Event(
        name=request.POST["new_name"],
        location=event.location,
        tasks_can_be_claimed=False,
        start_date=request.POST["new_start_date"],
        duration_days=event.duration_days,
    )
    new_event.save()
    for t in event.task_set.all():
        new_event.task_set.create(
            for_event=new_event,
            for_committee=t.for_committee,
            task_type=t.task_type,
            start_time=t.start_time,
            duration_minutes=t.duration_minutes,
            num_volunteers_needed=t.num_volunteers_needed,
            potential_points=t.potential_points,
            description=t.description,
        )
    new_event.save()
    query_params = [("event", new_event.id), ("volunteer", 0), ("show_unassigned", "on")]  # all volunteers
    return HttpResponseRedirect("/chirp/tasks/manage/?%s" % urllib.urlencode(query_params))
Пример #2
0
    def test_hide_expired_events(self):
        old_event = Event()
        old_event.name = "Pitchfork 2008"
        old_event.duration_days = 3
        # make it just expire by a day:
        old_event.start_date = datetime.datetime.now() - timedelta(days=4)
        old_event.save()

        some_task = Task()
        some_task.for_event = old_event
        some_task.for_committee = Committee.objects.filter(
                                            name="Events Committee").all()[0]
        some_task.task_type = TaskType.objects.filter(
                                            short_description="Tabling").all()[0]
        some_task.start_time = datetime.datetime.now() - timedelta(days=30)
        some_task.duration_minutes = 60
        some_task.num_volunteers = 1
        some_task.save()

        plainuser = User.objects.filter(username='******').all()[0]
        temp_volunteer = Volunteer()
        temp_volunteer.user = plainuser
        temp_volunteer.save()

        asn = TaskAssignment()
        asn.task = some_task
        asn.points = 1
        asn.volunteer = temp_volunteer
        asn.save()

        resp = self.client.get('/chirp/tasks/claim/')
        context = resp.context[0]

        eq_(sorted(e.name for e in context['events']),
            ['CHIRP Record Fair & Other Delights'])
Пример #3
0
def clone_event(request):
    if not request.POST:
        return HttpResponseForbidden()
    event = Event.objects.get(pk=request.POST['existing_event'])
    new_event = Event(name=request.POST['new_name'],
                      location=event.location,
                      tasks_can_be_claimed=False,
                      start_date=request.POST['new_start_date'],
                      duration_days=event.duration_days)
    new_event.save()
    for t in event.task_set.all():
        new_event.task_set.create(
            for_event=new_event,
            for_committee=t.for_committee,
            task_type=t.task_type,
            start_time=t.start_time,
            duration_minutes=t.duration_minutes,
            num_volunteers_needed=t.num_volunteers_needed,
            potential_points=t.potential_points,
            description=t.description)
    new_event.save()
    query_params = [
        ('event', new_event.id),
        ('volunteer', 0),  # all volunteers
        ('show_unassigned', 'on')
    ]
    return HttpResponseRedirect('/chirp/tasks/manage/?%s' %
                                urllib.urlencode(query_params))