示例#1
0
文件: api.py 项目: mcr/ietfdb
    def test_deleteAgendaSecretariat(self):
        mtg83 = get_meeting(83)
        a83   = mtg83.agenda
        self.assertNotEqual(a83, None)

        # try to delete an agenda
        resp = self.client.delete('/meeting/83/agendas/%s.json' % (a83.name), **auth_wlo)
        self.assertEqual(resp.status_code, 200)

        # see that in fact wlo can delete an existing room.
        mtg83 = get_meeting(83)
        a83c = mtg83.schedule_set.filter(pk = a83.pk).count()
        self.assertEqual(a83c, 0)
        self.assertEqual(mtg83.agenda, None)
示例#2
0
文件: api.py 项目: qiujianben/ietfdb
    def test_deleteAgendaSecretariat(self):
        mtg83 = get_meeting(83)
        a83 = mtg83.agenda
        self.assertNotEqual(a83, None)

        # try to delete an agenda
        resp = self.client.delete('/meeting/83/agendas/%s.json' % (a83.name),
                                  **auth_wlo)
        self.assertEqual(resp.status_code, 200)

        # see that in fact wlo can delete an existing room.
        mtg83 = get_meeting(83)
        a83c = mtg83.schedule_set.filter(pk=a83.pk).count()
        self.assertEqual(a83c, 0)
        self.assertEqual(mtg83.agenda, None)
示例#3
0
def edit_timeslots(request, num=None):

    meeting = get_meeting(num)
    timeslots = meeting.timeslot_set.exclude(location__isnull=True).all()

    time_slices, date_slices, slots = meeting.build_timeslices()

    meeting_base_url = meeting.url(request.get_host_protocol(), "")
    site_base_url = request.get_host_protocol()
    rooms = meeting.room_set.order_by("capacity")
    rooms = rooms.all()

    from ietf.meeting.ajax import timeslot_roomsurl, AddRoomForm, timeslot_slotsurl, AddSlotForm

    roomsurl = reverse(timeslot_roomsurl, args=[meeting.number])
    adddayurl = reverse(timeslot_slotsurl, args=[meeting.number])

    return HttpResponse(render_to_string(
        "meeting/timeslot_edit.html", {
            "timeslots": timeslots,
            "meeting_base_url": meeting_base_url,
            "site_base_url": site_base_url,
            "rooms": rooms,
            "addroom": AddRoomForm(),
            "roomsurl": roomsurl,
            "addday": AddSlotForm(),
            "adddayurl": adddayurl,
            "time_slices": time_slices,
            "slot_slices": slots,
            "date_slices": date_slices,
            "meeting": meeting
        }, RequestContext(request)),
                        mimetype="text/html")
示例#4
0
def get_lock_message(meeting=None):
    '''
    Returns the message to display to non-secretariat users when the tool is locked.
    '''
    if not meeting:
        meeting = get_meeting()
    return meeting.session_request_lock_message
示例#5
0
文件: api.py 项目: qiujianben/ietfdb
    def test_getSlotJson(self):
        mtg83 = get_meeting(83)
        slot0 = mtg83.timeslot_set.all()[0]

        resp = self.client.get('/meeting/83/timeslot/%s.json' % slot0.pk)
        slot0json = json.loads(resp.content)
        self.assertNotEqual(slot0json, None)
示例#6
0
def check_app_locked(meeting=None):
    '''
    This function returns True if the application is locked to non-secretariat users.
    '''
    if not meeting:
        meeting = get_meeting()
    return bool(meeting.session_request_lock_message)
示例#7
0
文件: api.py 项目: mcr/ietfdb
    def test_getAgendaJson(self):
        mtg83 = get_meeting(83)
        a83   = mtg83.agenda

        resp = self.client.get('/meeting/83/agendas/%s.json' % a83.name)
        a83json = json.loads(resp.content)
        self.assertNotEqual(a83json, None)
示例#8
0
文件: views.py 项目: ekr/ietfdb
def check_app_locked(meeting=None):
    '''
    This function returns True if the application is locked to non-secretariat users.
    '''
    if not meeting:
        meeting = get_meeting()
    return bool(meeting.session_request_lock_message)
示例#9
0
文件: api.py 项目: mcr/ietfdb
    def test_createNewRoomSecretariat(self):
        mtg83 = get_meeting(83)
        rm221 = mtg83.room_set.filter(name = '221')
        self.assertEqual(len(rm221), 0)

        timeslots = mtg83.timeslot_set.all()
        timeslot_initial_len = len(timeslots)
        self.assertTrue(timeslot_initial_len>0)

        extra_headers = auth_wlo
        extra_headers['HTTP_ACCEPT']='text/json'

        # try to create a new room
        self.client.post('/meeting/83/rooms', {
                'name' : '221',
                'capacity': 50,
            }, **extra_headers)

        # see that in fact wlo can create a new room.
        rm221 = mtg83.room_set.filter(name = '221')
        self.assertEqual(len(rm221), 1)

        timeslots = mtg83.timeslot_set.all()
        timeslot_final_len = len(timeslots)
        self.assertEqual((timeslot_final_len - timeslot_initial_len), 26)
示例#10
0
文件: api.py 项目: mcr/ietfdb
    def test_getSlotJson(self):
        mtg83 = get_meeting(83)
        slot0 = mtg83.timeslot_set.all()[0]

        resp = self.client.get('/meeting/83/timeslot/%s.json' % slot0.pk)
        slot0json = json.loads(resp.content)
        self.assertNotEqual(slot0json, None)
示例#11
0
def agenda_permission_api(request, num, owner, name):
    meeting = get_meeting(num)
    person = get_person_by_email(owner)
    schedule = get_schedule_by_name(meeting, person, name)

    save_perm = False
    secretariat = False
    cansee = False
    canedit = False
    owner_href = ""

    if schedule is not None:
        cansee, canedit, secretariat = agenda_permissions(
            meeting, schedule, request.user)
        owner_href = request.build_absolute_uri(schedule.owner.json_url())

    if has_role(request.user, "Area Director") or secretariat:
        save_perm = True

    return HttpResponse(json.dumps({
        'secretariat': secretariat,
        'save_perm': save_perm,
        'read_only': canedit == False,
        'owner_href': owner_href
    }),
                        content_type="application/json")
示例#12
0
文件: api.py 项目: mcr/ietfdb
    def test_getRoomJson(self):
        mtg83 = get_meeting(83)
        rm243 = mtg83.room_set.get(name = '243')

        resp = self.client.get('/meeting/83/room/%s.json' % rm243.pk)
        rm243json = json.loads(resp.content)
        self.assertNotEqual(rm243json, None)
示例#13
0
文件: views.py 项目: ekr/ietfdb
def get_lock_message(meeting=None):
    '''
    Returns the message to display to non-secretariat users when the tool is locked.
    '''
    if not meeting:
        meeting = get_meeting()
    return meeting.session_request_lock_message
示例#14
0
def edit_roomurl(request, num, roomid):
    meeting = get_meeting(num)

    try:
        room = meeting.room_set.get(pk=roomid)
    except Room.DoesNotExist:
        raise Http404("No room %u for meeting %s" % (roomid, meeting.name))

    if request.POST:
        roomform = RoomForm(request.POST, instance=room)
        new_room = roomform.save(commit=False)
        new_room.meeting = meeting
        new_room.save()
        roomform.save_m2m()
        return HttpResponseRedirect( reverse(edit_timeslots, args=[meeting.number]) )

    roomform = RoomForm(instance=room)
    meeting_base_url = request.build_absolute_uri(meeting.base_url())
    site_base_url = request.build_absolute_uri('/')[:-1] # skip the trailing slash
    return render(request, "meeting/room_edit.html",
                                         {"meeting_base_url": meeting_base_url,
                                          "site_base_url": site_base_url,
                                          "editroom":  roomform,
                                          "meeting":meeting,
                                          "hide_menu": True,
                                      })
示例#15
0
文件: ajax.py 项目: mcr/ietfdb
def readonly(request, meeting_num, schedule_id):
    meeting = get_meeting(meeting_num)
    schedule = get_schedule_by_id(meeting, schedule_id)

    secretariat = False
    write_perm  = False

    cansee,canedit = agenda_permissions(meeting, schedule, request.user)
    read_only = not canedit

    user = request.user
    if has_role(user, "Secretariat"):
        secretariat = True
        write_perm  = True

    if has_role(user, "Area Director"):
        write_perm  = True

    try:
        person = user.get_profile()
        if person is not None and schedule.owner == user.person:
            read_only = False
    except:
        # specific error if user has no profile...
        pass

    return json.dumps(
        {'secretariat': secretariat,
         'write_perm':  write_perm,
         'owner_href':  schedule.owner.url(request.get_host_protocol()),
         'read_only':   read_only})
示例#16
0
def agenda_by_type(request,num=None,type=None):
    meeting = get_meeting(num) 
    schedule = get_schedule(meeting)
    assignments = schedule.assignments.order_by('session__type__slug','timeslot__time')
    if type:
        assignments = assignments.filter(session__type__slug=type)
    return render(request,"meeting/agenda_by_type.html",{"meeting":meeting,"assignments":assignments})
示例#17
0
文件: agenda.py 项目: mcr/ietfdb
 def test_SessionUnicode(self):
     m1 = get_meeting("83")
     g1 = Group.objects.get(acronym = "pkix")
     p1 = Person.objects.get(pk = 5376)       # Russ Housley
     st1 = SessionStatusName.objects.get(slug = "appr")
     s1 = m1.session_set.create(name = "newone", group = g1, requested_by = p1, status = st1)
     self.assertEqual(s1.__unicode__(), "IETF-83: pkix (unscheduled)")
示例#18
0
文件: api.py 项目: qiujianben/ietfdb
    def test_getAgendaJson(self):
        mtg83 = get_meeting(83)
        a83 = mtg83.agenda

        resp = self.client.get('/meeting/83/agendas/%s.json' % a83.name)
        a83json = json.loads(resp.content)
        self.assertNotEqual(a83json, None)
示例#19
0
 def test_avtcore_has_two_slots(self):
     mtg83 = get_meeting(83)
     sch83 = get_schedule(mtg83, "mtg:83")
     avtcore = mtg83.session_set.get(group__acronym='avtcore')
     self.assertEqual(avtcore.pk, 2216)  # sanity check
     self.assertEqual(
         len(avtcore.scheduledsession_set.filter(schedule=sch83)), 2)
示例#20
0
def get_meeting_schedule(num, owner, name):
    meeting = get_meeting(num)
    person = get_person_by_email(owner)
    schedule = get_schedule_by_name(meeting, person, name)

    if schedule is None or person is None or meeting is None:
        meeting_pk = 0
        person_pk = 0
        schedule_pk = 0
        # to make diagnostics more meaningful, log what we found
        if meeting:
            meeting_pk = meeting.pk
        if person:
            person_pk = person.pk
        if schedule:
            schedule_pk = schedule.pk
        return HttpResponse(json.dumps({
            'error':
            'invalid meeting=%s/person=%s/schedule=%s' % (num, owner, name),
            'meeting':
            meeting_pk,
            'person':
            person_pk,
            'schedule':
            schedule_pk
        }),
                            content_type="application/json",
                            status=404)
    return meeting, person, schedule
示例#21
0
文件: api.py 项目: qiujianben/ietfdb
    def test_getRoomJson(self):
        mtg83 = get_meeting(83)
        rm243 = mtg83.room_set.get(name='243')

        resp = self.client.get('/meeting/83/room/%s.json' % rm243.pk)
        rm243json = json.loads(resp.content)
        self.assertNotEqual(rm243json, None)
示例#22
0
文件: api.py 项目: qiujianben/ietfdb
    def test_createNewRoomSecretariat(self):
        mtg83 = get_meeting(83)
        rm221 = mtg83.room_set.filter(name='221')
        self.assertEqual(len(rm221), 0)

        timeslots = mtg83.timeslot_set.all()
        timeslot_initial_len = len(timeslots)
        self.assertTrue(timeslot_initial_len > 0)

        extra_headers = auth_wlo
        extra_headers['HTTP_ACCEPT'] = 'text/json'

        # try to create a new room
        self.client.post('/meeting/83/rooms', {
            'name': '221',
            'capacity': 50,
        }, **extra_headers)

        # see that in fact wlo can create a new room.
        rm221 = mtg83.room_set.filter(name='221')
        self.assertEqual(len(rm221), 1)

        timeslots = mtg83.timeslot_set.all()
        timeslot_final_len = len(timeslots)
        self.assertEqual((timeslot_final_len - timeslot_initial_len), 26)
示例#23
0
def materials(request, meeting_num=None):
    meeting = get_meeting(meeting_num)

    begin_date = meeting.get_submission_start_date()
    cut_off_date = meeting.get_submission_cut_off_date()
    cor_cut_off_date = meeting.get_submission_correction_date()
    now = datetime.date.today()
    if settings.SERVER_MODE != 'production' and '_testoverride' in request.REQUEST:
        pass
    elif now > cor_cut_off_date:
        return render(request, "meeting/materials_upload_closed.html", {
            'meeting_num': meeting_num,
            'begin_date': begin_date,
            'cut_off_date': cut_off_date,
            'cor_cut_off_date': cor_cut_off_date
        })

    #sessions  = Session.objects.filter(meeting__number=meeting_num, timeslot__isnull=False)
    schedule = get_schedule(meeting, None)
    sessions  = Session.objects.filter(meeting__number=meeting_num, timeslotassignments__schedule=schedule).select_related()
    plenaries = sessions.filter(name__icontains='plenary')
    ietf      = sessions.filter(group__parent__type__slug = 'area').exclude(group__acronym='edu')
    irtf      = sessions.filter(group__parent__acronym = 'irtf')
    training  = sessions.filter(group__acronym__in=['edu','iaoc'])
    iab       = sessions.filter(group__parent__acronym = 'iab')

    cache_version = Document.objects.filter(session__meeting__number=meeting_num).aggregate(Max('time'))["time__max"]
    return render(request, "meeting/materials.html", {
        'meeting_num': meeting_num,
        'plenaries': plenaries, 'ietf': ietf, 'training': training, 'irtf': irtf, 'iab': iab,
        'cut_off_date': cut_off_date,
        'cor_cut_off_date': cor_cut_off_date,
        'submission_started': now > begin_date,
        'cache_version': cache_version,
    })
示例#24
0
def edit_timeslots(request, num=None):

    meeting = get_meeting(num)
    timeslots = meeting.timeslot_set.exclude(location=None).select_related("location", "type")

    time_slices,date_slices,slots = meeting.build_timeslices()

    meeting_base_url = request.build_absolute_uri(meeting.base_url())
    site_base_url = request.build_absolute_uri('/')[:-1] # skip the trailing slash

    rooms = meeting.room_set.order_by("capacity")

    # this import locate here to break cyclic loop.
    from ietf.meeting.ajax import timeslot_roomsurl, AddRoomForm, timeslot_slotsurl, AddSlotForm
    roomsurl  = reverse(timeslot_roomsurl, args=[meeting.number])
    adddayurl = reverse(timeslot_slotsurl, args=[meeting.number])

    return render(request, "meeting/timeslot_edit.html",
                                         {"timeslots": timeslots,
                                          "meeting_base_url": meeting_base_url,
                                          "site_base_url": site_base_url,
                                          "rooms":rooms,
                                          "addroom":  AddRoomForm(),
                                          "roomsurl": roomsurl,
                                          "addday":   AddSlotForm(),
                                          "adddayurl":adddayurl,
                                          "time_slices":time_slices,
                                          "slot_slices": slots,
                                          "date_slices":date_slices,
                                          "meeting":meeting,
                                          "hide_menu": True,
                                      })
示例#25
0
文件: views.py 项目: algby/ietfdb
def main(request):
    '''
    Display list of groups the user has access to.

    Template variables
    form: a select box populated with unscheduled groups
    meeting: the current meeting
    scheduled_sessions:
    '''
    # check for locked flag
    is_locked = check_app_locked()

    if is_locked and not has_role(request.user,'Secretariat'):
        message = get_lock_message()
        return render_to_response('sreq/locked.html', {
        'message': message},
        RequestContext(request, {}),
    )

    # TODO this is not currently used in the main template
    if request.method == 'POST':
        button_text = request.POST.get('submit', '')
        if button_text == 'Group will not meet':
            return redirect('sessions_no_session', acronym=request.POST['group'])
        else:
            return redirect('sessions_new', acronym=request.POST['group'])

    meeting = get_meeting()
    scheduled_groups,unscheduled_groups = groups_by_session(request.user, meeting)

    # warn if there are no associated groups
    if not scheduled_groups and not unscheduled_groups:
        messages.warning(request, 'The account %s is not associated with any groups.  If you have multiple Datatracker accounts you may try another or report a problem to [email protected]' % request.user)
     
    # load form select with unscheduled groups
    choices = zip([ g.pk for g in unscheduled_groups ],
                  [ str(g) for g in unscheduled_groups ])
    form = GroupSelectForm(choices=choices)

    # add session status messages for use in template
    for group in scheduled_groups:
        sessions = group.session_set.filter(meeting=meeting)
        if sessions.count() < 3:
            group.status_message = sessions[0].status
        else:
            group.status_message = 'First two sessions: %s, Third session: %s' % (sessions[0].status,sessions[2].status)

    # add not meeting indicators for use in template
    for group in unscheduled_groups:
        if group.session_set.filter(meeting=meeting,status='notmeet'):
            group.not_meeting = True

    return render_to_response('sreq/main.html', {
        'is_locked': is_locked,
        'form': form,
        'meeting': meeting,
        'scheduled_groups': scheduled_groups,
        'unscheduled_groups': unscheduled_groups},
        RequestContext(request, {}),
    )
示例#26
0
文件: views.py 项目: algby/ietfdb
def week_view(request, num=None):
    meeting = get_meeting(num)
    timeslots = TimeSlot.objects.filter(meeting=meeting)

    template = "meeting/week-view.html"
    return render_to_response(template,
            {"timeslots":timeslots,"render_types":["Session","Other","Break","Plenary"]}, context_instance=RequestContext(request))
示例#27
0
文件: views.py 项目: mcr/ietfdb
def materials(request, meeting_num=None, schedule_name=None):
    proceeding = get_object_or_404(Proceeding, meeting_num=meeting_num)
    begin_date = proceeding.sub_begin_date
    cut_off_date = proceeding.sub_cut_off_date
    cor_cut_off_date = proceeding.c_sub_cut_off_date
    now = datetime.date.today()
    if settings.SERVER_MODE != 'production' and '_testoverride' in request.REQUEST:
        pass
    elif now > cor_cut_off_date:
        return render_to_response("meeting/materials_upload_closed.html",{'meeting_num':meeting_num,'begin_date':begin_date, 'cut_off_date':cut_off_date, 'cor_cut_off_date':cor_cut_off_date}, context_instance=RequestContext(request))
    sub_began = 0
    if now > begin_date:
        sub_began = 1

    meeting = get_meeting(meeting_num)
    schedule = get_schedule(meeting, schedule_name)

    scheduledsessions = get_scheduledsessions_from_schedule(schedule)

    plenaries = scheduledsessions.filter(session__name__icontains='plenary')
    ietf      = scheduledsessions.filter(session__group__parent__type__slug = 'area').exclude(session__group__acronym='edu')
    irtf      = scheduledsessions.filter(session__group__parent__acronym = 'irtf')
    training  = scheduledsessions.filter(session__group__acronym='edu')
    iab       = scheduledsessions.filter(session__group__parent__acronym = 'iab')

    cache_version = Document.objects.filter(session__meeting__number=meeting_num).aggregate(Max('time'))["time__max"]
    #
    return render_to_response("meeting/materials.html",
                              {'meeting_num':meeting_num,
                               'plenaries': plenaries, 'ietf':ietf, 'training':training, 'irtf': irtf, 'iab':iab,
                               'begin_date':begin_date, 'cut_off_date':cut_off_date,
                               'cor_cut_off_date':cor_cut_off_date,'sub_began':sub_began,
                               'cache_version':cache_version},
                              context_instance=RequestContext(request))
示例#28
0
文件: views.py 项目: mcr/ietfdb
def edit_timeslots(request, num=None):

    meeting = get_meeting(num)
    timeslots = meeting.timeslot_set.exclude(location__isnull = True).all()

    time_slices,date_slices,slots = meeting.build_timeslices()

    meeting_base_url = meeting.url(request.get_host_protocol(), "")
    site_base_url =request.get_host_protocol()
    rooms = meeting.room_set.order_by("capacity")
    rooms = rooms.all()

    from ietf.meeting.ajax import timeslot_roomsurl, AddRoomForm, timeslot_slotsurl, AddSlotForm

    roomsurl  =reverse(timeslot_roomsurl, args=[meeting.number])
    adddayurl =reverse(timeslot_slotsurl, args=[meeting.number])

    return HttpResponse(render_to_string("meeting/timeslot_edit.html",
                                         {"timeslots": timeslots,
                                          "meeting_base_url": meeting_base_url,
                                          "site_base_url": site_base_url,
                                          "rooms":rooms,
                                          "addroom":  AddRoomForm(),
                                          "roomsurl": roomsurl,
                                          "addday":   AddSlotForm(),
                                          "adddayurl":adddayurl,
                                          "time_slices":time_slices,
                                          "slot_slices": slots,
                                          "date_slices":date_slices,
                                          "meeting":meeting},
                                         RequestContext(request)), mimetype="text/html")
示例#29
0
def new(request, acronym):
    '''
    This view gathers details for a new session request.  The user proceeds to confirm()
    to create the request.
    '''
    group = get_object_or_404(Group, acronym=acronym)
    meeting = get_meeting()
    session_conflicts = session_conflicts_as_string(group, meeting)

    # check if app is locked
    is_locked = check_app_locked()
    if is_locked and not has_role(request.user,'Secretariat'):
        messages.warning(request, "The Session Request Tool is closed")
        return redirect('sessions')
    
    if request.method == 'POST':
        button_text = request.POST.get('submit', '')
        if button_text == 'Cancel':
            return redirect('sessions')

        form = SessionForm(request.POST)
        if form.is_valid():
            # check if request already exists for this group
            if Session.objects.filter(group=group,meeting=meeting).exclude(status__in=('deleted','notmeet')):
                messages.warning(request, 'Sessions for working group %s have already been requested once.' % group.acronym)
                return redirect('sessions')

            # save in user session
            request.session['session_form'] = form.data

            return redirect('sessions_confirm',acronym=acronym)

    # the "previous" querystring causes the form to be returned
    # pre-populated with data from last meeeting's session request
    elif request.method == 'GET' and request.GET.has_key('previous'):
        previous_meeting = Meeting.objects.get(number=str(int(meeting.number) - 1))
        previous_sessions = Session.objects.filter(meeting=previous_meeting,group=group).exclude(status__in=('notmeet','deleted')).order_by('id')
        if not previous_sessions:
            messages.warning(request, 'This group did not meet at %s' % previous_meeting)
            return redirect('sessions_new', acronym=acronym)

        initial = get_initial_session(previous_sessions)
        add_essential_people(group,initial)
        if 'resources' in initial:
            initial['resources'] = [x.pk for x in initial['resources']]
        form = SessionForm(initial=initial)

    else:
        initial={}
        add_essential_people(group,initial)
        form = SessionForm(initial=initial)

    return render_to_response('sreq/new.html', {
        'meeting': meeting,
        'form': form,
        'group': group,
        'session_conflicts': session_conflicts},
        RequestContext(request, {}),
    )
示例#30
0
文件: autoplace.py 项目: algby/ietfdb
    def handle(self, *labels, **options):
        self.verbose  = options.get('verbose', 1)

        meetingname = labels[0]
        schedname   = labels[1]
        targetname  = None
        if labels[2] is not None:
            targetname = labels[2]

        seed    = options.get('seed', None)
        maxstep = options.get('maxstep', 20000)
        verbose = options.get('verbose', False)
        profile = options.get('profile', False)
        recordsteps = options.get('recordsteps', False)

        from ietf.meeting.helpers import get_meeting
        try:
            meeting = get_meeting(meetingname)
        except Meeting.DoesNotExist:
            print "No such meeting: %s" % (meetingname)
            return

        try:
            schedule = meeting.schedule_set.get(name = schedname)
        except Schedule.DoesNotExist:
            print "No such schedule: %s in meeting: %s" % (schedname, meeting)
            return

        if targetname is not None:
            try:
                targetsched = meeting.schedule_set.get(name=targetname)
            except Schedule.DoesNotExist:
                print "Creating new schedule %s" % (targetname)
                targetsched = Schedule(meeting = meeting,
                                       owner   = schedule.owner,
                                       name = targetname)
                targetsched.save()
        else:
            targetsched = schedule

        print "Saving results to %s" % (targetsched.name)

        from ietf.meeting.placement import CurrentScheduleState
        css = CurrentScheduleState(schedule, seed)
        css.recordsteps = recordsteps
        css.verbose     = verbose

        if profile:
            import cProfile
            cProfile.runctx('css.do_placement(maxstep, targetsched)',
                            vars(),
                            vars(),
                            'placestats.pyprof')

            import pstats
            p = pstats.Stats('placestats.pyprof')
            p.strip_dirs().sort_stats(-1).print_stats()
        else:
            css.do_placement(maxstep, targetsched)
示例#31
0
文件: ajax.py 项目: algby/ietfdb
def sessions_json(request, num):
    meeting = get_meeting(num)

    sessions = meeting.sessions_that_can_meet.all()

    sess1_dict = [ x.json_dict(request.build_absolute_uri('/')) for x in sessions ]
    return HttpResponse(json.dumps(sess1_dict, sort_keys=True, indent=2),
                        content_type="application/json")
示例#32
0
文件: api.py 项目: mcr/ietfdb
    def test_setMeetingAgendaNoneSecretariat(self):
        mtg83 = get_meeting(83)
        self.assertNotEqual(mtg83.agenda, None)

        extra_headers = auth_wlo
        extra_headers['HTTP_ACCEPT']='application/json'

        # try to create a new agenda
        resp = self.client.post('/meeting/83.json',
                                data="agenda=None",
                                content_type="application/x-www-form-urlencoded",
                                **extra_headers)
        self.assertEqual(resp.status_code, 200)

        # new to reload the object
        mtg83 = get_meeting(83)
        self.assertEqual(mtg83.agenda, None)
示例#33
0
def agenda_by_type_ics(request,num=None,type=None):
    meeting = get_meeting(num) 
    schedule = get_schedule(meeting)
    assignments = schedule.assignments.order_by('session__type__slug','timeslot__time')
    if type:
        assignments = assignments.filter(session__type__slug=type)
    updated = meeting.updated()
    return render(request,"meeting/agenda.ics",{"schedule":schedule,"updated":updated,"assignments":assignments},content_type="text/calendar")
示例#34
0
def week_view(request, num=None):
    meeting = get_meeting(num)
    schedule = get_schedule(meeting)

    if not schedule:
        raise Http404

    filtered_assignments = schedule.assignments.exclude(timeslot__type__in=['lead','offagenda'])
    filtered_assignments = preprocess_assignments_for_agenda(filtered_assignments, meeting)
    
    items = []
    for a in filtered_assignments:
        # we don't HTML escape any of these as the week-view code is using createTextNode
        item = {
            "key": str(a.timeslot.pk),
            "day": a.timeslot.time.strftime("%w"),
            "time": a.timeslot.time.strftime("%H%M") + "-" + a.timeslot.end_time().strftime("%H%M"),
            "duration": a.timeslot.duration.seconds,
            "time_id": a.timeslot.time.strftime("%m%d%H%M"),
            "dayname": "{weekday}, {month} {day_of_month}, {year}".format(
                weekday=a.timeslot.time.strftime("%A").upper(),
                month=a.timeslot.time.strftime("%B"),
                day_of_month=a.timeslot.time.strftime("%d").lstrip("0"),
                year=a.timeslot.time.strftime("%Y"),
            ),
            "type": a.timeslot.type.name
        }

        if a.session:
            if a.session.historic_group:
                item["group"] = a.session.historic_group.acronym

            if a.session.name:
                item["name"] = a.session.name
            elif a.timeslot.type_id == "break":
                item["name"] = a.timeslot.name
                item["area"] = a.timeslot.type_id
                item["group"] = a.timeslot.type_id
            elif a.session.historic_group:
                item["name"] = a.session.historic_group.name
                if a.session.historic_group.state_id == "bof":
                    item["name"] += " BOF"

                item["state"] = a.session.historic_group.state.name
                if a.session.historic_group.historic_parent:
                    item["area"] = a.session.historic_group.historic_parent.acronym

            if a.timeslot.show_location:
                item["room"] = a.timeslot.get_location()

            if a.session and a.session.agenda():
                item["agenda"] = a.session.agenda().get_absolute_url()

        items.append(item)

    return render(request, "meeting/week-view.html", {
        "items": json.dumps(items),
    })
示例#35
0
文件: api.py 项目: qiujianben/ietfdb
    def test_setMeetingAgendaNoneSecretariat(self):
        mtg83 = get_meeting(83)
        self.assertNotEqual(mtg83.agenda, None)

        extra_headers = auth_wlo
        extra_headers['HTTP_ACCEPT'] = 'application/json'

        # try to create a new agenda
        resp = self.client.post(
            '/meeting/83.json',
            data="agenda=None",
            content_type="application/x-www-form-urlencoded",
            **extra_headers)
        self.assertEqual(resp.status_code, 200)

        # new to reload the object
        mtg83 = get_meeting(83)
        self.assertEqual(mtg83.agenda, None)
示例#36
0
文件: api.py 项目: qiujianben/ietfdb
    def test_createNewAgendaSecretariat(self):
        mtg83 = get_meeting(83)
        a83 = mtg83.agenda

        extra_headers = auth_wlo
        extra_headers['HTTP_ACCEPT'] = 'text/json'

        # try to create a new agenda
        resp = self.client.post('/meeting/83/agendas', {
            'name': 'fakeagenda1',
        }, **extra_headers)

        self.assertEqual(resp.status_code, 302)

        # see that in fact wlo can create a new timeslot
        mtg83 = get_meeting(83)
        n83 = mtg83.schedule_set.filter(name='fakeagenda1')
        self.assertNotEqual(n83, None)
示例#37
0
文件: agenda.py 项目: mcr/ietfdb
 def test_DoNotGetSchedule(self):
     from django.http import Http404
     num = '83'
     from ietf.meeting.views import get_meeting, get_schedule
     meeting = get_meeting(num)
     try:
         na = get_schedule(meeting, "none:83")
     except Http404:
         False
示例#38
0
 def test_DoNotGetSchedule(self):
     from django.http import Http404
     num = '83'
     from ietf.meeting.views import get_meeting, get_schedule
     meeting = get_meeting(num)
     try:
         na = get_schedule(meeting, "none:83")
     except Http404:
         False
示例#39
0
def meeting_json(request, num):
    meeting = get_meeting(num)

    if request.method == 'GET':
        return meeting_get(request, meeting)
    elif request.method == 'POST':
        return meeting_update(request, meeting)
    else:
        return HttpResponse(status=406)
示例#40
0
def meeting_requests(request, num=None):
    meeting = get_meeting(num)
    sessions = Session.objects.filter(meeting__number=meeting.number, type__slug='session', group__parent__isnull = False).exclude(requested_by=0).order_by("group__parent__acronym","status__slug","group__acronym")

    groups_not_meeting = Group.objects.filter(state='Active',type__in=['WG','RG','BOF']).exclude(acronym__in = [session.group.acronym for session in sessions]).order_by("parent__acronym","acronym")

    return render(request, "meeting/requests.html",
        {"meeting": meeting, "sessions":sessions,
         "groups_not_meeting": groups_not_meeting})
示例#41
0
文件: api.py 项目: mcr/ietfdb
    def test_createNewAgendaSecretariat(self):
        mtg83 = get_meeting(83)
        a83   = mtg83.agenda

        extra_headers = auth_wlo
        extra_headers['HTTP_ACCEPT']='text/json'

        # try to create a new agenda
        resp = self.client.post('/meeting/83/agendas', {
                'name' : 'fakeagenda1',
            }, **extra_headers)

        self.assertEqual(resp.status_code, 302)

        # see that in fact wlo can create a new timeslot
        mtg83 = get_meeting(83)
        n83 = mtg83.schedule_set.filter(name='fakeagenda1')
        self.assertNotEqual(n83, None)
示例#42
0
文件: ajax.py 项目: algby/ietfdb
def meeting_json(request, num):
    meeting = get_meeting(num)

    if request.method == 'GET':
        return meeting_get(request, meeting)
    elif request.method == 'POST':
        return meeting_update(request, meeting)
    else:
        return HttpResponse(status=406)
示例#43
0
文件: views.py 项目: mcr/ietfdb
def ical_agenda(request, num=None, schedule_name=None):
    meeting = get_meeting(num)

    q = request.META.get('QUERY_STRING','') or ""
    filter = urllib.unquote(q).lower().split(',');
    include = set(filter)
    include_types = set(["Plenary","Other"])
    exclude = []

    # Process the special flags.
    #   "-wgname" will remove a working group from the output.
    #   "~Type" will add that type to the output.
    #   "-~Type" will remove that type from the output
    # Current types are:
    #   Session, Other (default on), Break, Plenary (default on)
    # Non-Working Group "wg names" include:
    #   edu, ietf, tools, iesg, iab

    for item in include:
        if item:
            if item[0] == '-' and item[1] == '~':
                include_types -= set([item[2:3].upper()+item[3:]])
            elif item[0] == '-':
                exclude.append(item[1:])
            elif item[0] == '~':
                include_types |= set([item[1:2].upper()+item[2:]])

    schedule = get_schedule(meeting, schedule_name)
    scheduledsessions = get_scheduledsessions_from_schedule(schedule)

    scheduledsessions = scheduledsessions.filter(
        Q(timeslot__type__name__in = include_types) |
        Q(session__group__acronym__in = filter) |
        Q(session__group__parent__acronym__in = filter)
        ).exclude(Q(session__group__acronym__in = exclude))
        #.exclude(Q(session__group__isnull = False),
        #Q(session__group__acronym__in = exclude) |
        #Q(session__group__parent__acronym__in = exclude))

    if meeting.time_zone:
        try:
            tzfn = os.path.join(settings.TZDATA_ICS_PATH, meeting.time_zone + ".ics")
            tzf = open(tzfn)
            icstext = tzf.read()
            debug.show('icstext[:128]')
            vtimezone = re.search("(?sm)(\nBEGIN:VTIMEZONE.*\nEND:VTIMEZONE\n)", icstext).group(1).strip()
            debug.show('vtimezone[:128]')
            tzf.close()
        except IOError:
            vtimezone = None
    else:
        vtimezone = None

    return HttpResponse(render_to_string("meeting/agendaREDESIGN.ics",
        {"scheduledsessions":scheduledsessions, "meeting":meeting, "vtimezone": vtimezone },
        RequestContext(request)), mimetype="text/calendar")
示例#44
0
def timeslot_slotsurl(request, num=None):
    meeting = get_meeting(num)

    if request.method == 'GET':
        return timeslot_slotlist(request, meeting)
    elif request.method == 'POST':
        return timeslot_addslot(request, meeting)

    # unacceptable reply
    return HttpResponse(status=406)
示例#45
0
文件: ajax.py 项目: mcr/ietfdb
def agenda_infosurl(request, num=None):
    meeting = get_meeting(num)

    if request.method == 'GET':
        return agenda_list(request, meeting)
    elif request.method == 'POST':
        return agenda_add(request, meeting)

    # unacceptable action
    return HttpResponse(status=406)
示例#46
0
def agenda_infosurl(request, num=None):
    meeting = get_meeting(num)

    if request.method == 'GET':
        return agenda_list(request, meeting)
    elif request.method == 'POST':
        return agenda_add(request, meeting)

    # unacceptable action
    return HttpResponse(status=406)
示例#47
0
def sessions_json(request, num):
    meeting = get_meeting(num)

    sessions = meeting.sessions_that_can_meet.all()

    sess1_dict = [
        x.json_dict(request.build_absolute_uri('/')) for x in sessions
    ]
    return HttpResponse(json.dumps(sess1_dict, sort_keys=True, indent=2),
                        content_type="application/json")
示例#48
0
 def test_SessionUnicode(self):
     m1 = get_meeting("83")
     g1 = Group.objects.get(acronym="pkix")
     p1 = Person.objects.get(pk=5376)  # Russ Housley
     st1 = SessionStatusName.objects.get(slug="appr")
     s1 = m1.session_set.create(name="newone",
                                group=g1,
                                requested_by=p1,
                                status=st1)
     self.assertEqual(s1.__unicode__(), "IETF-83: pkix (unscheduled)")
示例#49
0
def agenda_by_room(request,num=None):
    meeting = get_meeting(num) 
    schedule = get_schedule(meeting)
    ss_by_day = OrderedDict()
    for day in schedule.assignments.dates('timeslot__time','day'):
        ss_by_day[day]=[]
    for ss in schedule.assignments.order_by('timeslot__location__functional_name','timeslot__location__name','timeslot__time'):
        day = ss.timeslot.time.date()
        ss_by_day[day].append(ss)
    return render(request,"meeting/agenda_by_room.html",{"meeting":meeting,"ss_by_day":ss_by_day})
示例#50
0
文件: views.py 项目: ekr/ietfdb
def new(request, acronym):
    '''
    This view gathers details for a new session request.  The user proceeds to confirm()
    to create the request.
    '''
    group = get_object_or_404(Group, acronym=acronym)
    meeting = get_meeting()
    session_conflicts = session_conflicts_as_string(group, meeting)

    # check if app is locked
    is_locked = check_app_locked()
    if is_locked and not has_role(request.user,'Secretariat'):
        messages.warning(request, "The Session Request Tool is closed")
        return redirect('ietf.secr.sreq.views.main')
    
    if request.method == 'POST':
        button_text = request.POST.get('submit', '')
        if button_text == 'Cancel':
            return redirect('ietf.secr.sreq.views.main')

        form = SessionForm(request.POST)
        if form.is_valid():
            # check if request already exists for this group
            if Session.objects.filter(group=group,meeting=meeting).exclude(status__in=('deleted','notmeet')):
                messages.warning(request, 'Sessions for working group %s have already been requested once.' % group.acronym)
                return redirect('ietf.secr.sreq.views.main')
            return confirm(request, acronym)

    # the "previous" querystring causes the form to be returned
    # pre-populated with data from last meeeting's session request
    elif request.method == 'GET' and request.GET.has_key('previous'):
        previous_meeting = Meeting.objects.get(number=str(int(meeting.number) - 1))
        previous_sessions = Session.objects.filter(meeting=previous_meeting,group=group).exclude(status__in=('notmeet','deleted')).order_by('id')
        if not previous_sessions:
            messages.warning(request, 'This group did not meet at %s' % previous_meeting)
            return redirect('ietf.secr.sreq.views.new', acronym=acronym)

        initial = get_initial_session(previous_sessions)
        add_essential_people(group,initial)
        if 'resources' in initial:
            initial['resources'] = [x.pk for x in initial['resources']]
        form = SessionForm(initial=initial)

    else:
        initial={}
        add_essential_people(group,initial)
        form = SessionForm(initial=initial)

    return render(request, 'sreq/new.html', {
        'meeting': meeting,
        'form': form,
        'group': group,
        'session_conflicts': session_conflicts},
    )
示例#51
0
def week_view(request, num=None):
    meeting = get_meeting(num)
    timeslots = TimeSlot.objects.filter(meeting__id=meeting.id)

    template = "meeting/week-view.html"
    return render_to_response(
        template, {
            "timeslots": timeslots,
            "render_types": ["Session", "Other", "Break", "Plenary"]
        },
        context_instance=RequestContext(request))
示例#52
0
文件: api.py 项目: qiujianben/ietfdb
    def test_deleteNewSlotSecretariat(self):
        mtg83 = get_meeting(83)
        slot0 = mtg83.timeslot_set.all()[0]

        # try to delete a new room
        self.client.delete('/meeting/83/timeslot/%s.json' % (slot0.pk),
                           **auth_wlo)

        # see that in fact wlo can delete an existing room.
        slot0n = mtg83.timeslot_set.filter(pk=slot0.pk)
        self.assertEqual(len(slot0n), 0)
示例#53
0
def edit_agenda_properties(request, num=None, schedule_name=None):

    meeting = get_meeting(num)
    schedule = get_schedule(meeting, schedule_name)
    form = AgendaPropertiesForm(instance=schedule)

    return HttpResponse(render_to_string("meeting/properties_edit.html", {
        "schedule": schedule,
        "form": form,
        "meeting": meeting
    }, RequestContext(request)),
                        mimetype="text/html")
示例#54
0
def timeslot_sloturl(request, num=None, slotid=None):
    meeting = get_meeting(num)

    if request.method == 'GET':
        slot = get_object_or_404(meeting.timeslot_set, pk=slotid)
        return HttpResponse(json.dumps(
            slot.json_dict(request.build_absolute_uri('/'))),
                            content_type="application/json")
    elif request.method == 'POST' or request.method == 'PUT':
        return timeslot_updslot(request, meeting, slotid)
    elif request.method == 'DELETE':
        return timeslot_delslot(request, meeting, slotid)
示例#55
0
文件: api.py 项目: qiujianben/ietfdb
    def test_updateAgendaSecretariat(self):
        mtg83 = get_meeting(83)
        a83 = mtg83.agenda
        self.assertTrue(a83.visible)

        extra_headers = auth_wlo
        extra_headers['HTTP_ACCEPT'] = 'application/json'

        # try to create a new agenda
        resp = self.client.put(
            '/meeting/83/agendas/%s.json' % (a83.name),
            data='visible=0',
            content_type="application/x-www-form-urlencoded",
            **extra_headers)

        self.assertEqual(resp.status_code, 200)

        # see that in fact wlo can create a new timeslot
        mtg83 = get_meeting(83)
        a83 = mtg83.agenda
        self.assertFalse(a83.visible)
示例#56
0
文件: api.py 项目: qiujianben/ietfdb
    def test_setMeetingAgendaSecretariat(self):
        mtg83 = get_meeting(83)
        new_sched = mtg83.schedule_set.create(name="funny",
                                              meeting=mtg83,
                                              owner=mtg83.agenda.owner)
        self.assertNotEqual(mtg83.agenda, new_sched)

        extra_headers = auth_wlo
        extra_headers['HTTP_ACCEPT'] = 'text/json'

        # try to create a new agenda
        resp = self.client.put(
            '/meeting/83.json',
            data="agenda=%s" % new_sched.name,
            content_type="application/x-www-form-urlencoded",
            **extra_headers)
        self.assertEqual(resp.status_code, 200)

        # new to reload the object
        mtg83 = get_meeting(83)
        self.assertEqual(mtg83.agenda, new_sched)
示例#57
0
文件: views.py 项目: ekr/ietfdb
def view(request, acronym, num = None):
    '''
    This view displays the session request info
    '''
    meeting = get_meeting(num)
    group = get_object_or_404(Group, acronym=acronym)
    sessions = Session.objects.filter(~Q(status__in=('canceled','notmeet','deleted')),meeting=meeting,group=group).order_by('id')

    # check if app is locked
    is_locked = check_app_locked()
    if is_locked:
        messages.warning(request, "The Session Request Tool is closed")
        
    # if there are no session requests yet, redirect to new session request page
    if not sessions:
        if is_locked:
            return redirect('ietf.secr.sreq.views.main')
        else:
            return redirect('ietf.secr.sreq.views.new', acronym=acronym)

    # TODO simulate activity records
    activities = [{'act_date':sessions[0].requested.strftime('%b %d, %Y'),
                   'act_time':sessions[0].requested.strftime('%H:%M:%S'),
                   'activity':'New session was requested',
                   'act_by':sessions[0].requested_by}]
    if sessions[0].scheduled:
        activities.append({'act_date':sessions[0].scheduled.strftime('%b %d, %Y'),
                       'act_time':sessions[0].scheduled.strftime('%H:%M:%S'),
                       'activity':'Session was scheduled',
                       'act_by':'Secretariat'})

    # other groups that list this group in their conflicts
    session_conflicts = session_conflicts_as_string(group, meeting)
    show_approve_button = False

    # if sessions include a 3rd session waiting approval and the user is a secretariat or AD of the group
    # display approve button
    if sessions.filter(status='apprw'):
        if has_role(request.user,'Secretariat') or group.parent.role_set.filter(name='ad',person=request.user.person):
            show_approve_button = True

    # build session dictionary (like querydict from new session request form) for use in template
    session = get_initial_session(sessions)

    return render(request, 'sreq/view.html', {
        'is_locked': is_locked,
        'session': session,
        'activities': activities,
        'meeting': meeting,
        'group': group,
        'session_conflicts': session_conflicts,
        'show_approve_button': show_approve_button},
    )
示例#58
0
def timeslot_roomurl(request, num=None, roomid=None):
    meeting = get_meeting(num)

    if request.method == 'GET':
        room = get_object_or_404(meeting.room_set, pk=roomid)
        return HttpResponse(json.dumps(
            room.json_dict(request.build_absolute_uri('/'))),
                            content_type="application/json")
    elif request.method == 'PUT':
        return timeslot_updroom(request, meeting, roomid)
    elif request.method == 'DELETE':
        return timeslot_delroom(request, meeting, roomid)
示例#59
0
文件: views.py 项目: ekr/ietfdb
def add(request):
    '''
    Add a new IETF Meeting.  Creates Meeting and Proceeding objects.

    **Templates:**

    * ``meetings/add.html``

    **Template Variables:**

    * proceedingform

    '''
    if request.method == 'POST':
        button_text = request.POST.get('submit', '')
        if button_text == 'Cancel':
            return redirect('ietf.secr.meetings.views.main')

        form = MeetingModelForm(request.POST)
        if form.is_valid():
            meeting = form.save()

            schedule = Schedule.objects.create(meeting = meeting,
                                               name    = 'Empty-Schedule',
                                               owner   = Person.objects.get(name='(System)'),
                                               visible = True,
                                               public  = True)
            meeting.agenda = schedule
            
            # we want to carry session request lock status over from previous meeting
            previous_meeting = get_meeting( int(meeting.number) - 1 )
            meeting.session_request_lock_message = previous_meeting.session_request_lock_message
            meeting.save()

            populate_important_dates(meeting)

            # copy special sessions from previous meeting
            build_nonsession(meeting,schedule)
            
            # Create Physical new meeting directory and subdirectories
            make_materials_directories(meeting)

            messages.success(request, 'The Meeting was created successfully!')
            return redirect('ietf.secr.meetings.views.main')
    else:
        # display initial forms
        max_number = Meeting.objects.filter(type='ietf').aggregate(Max('number'))['number__max']
        form = MeetingModelForm(initial={'number':int(max_number) + 1})

    return render(request, 'meetings/add.html', {
        'form': form},
    )
示例#60
0
文件: api.py 项目: qiujianben/ietfdb
    def test_setMeetingAgendaNonSecretariat(self):
        mtg83 = get_meeting(83)
        self.assertNotEqual(mtg83.agenda, None)

        # try to create a new agenda
        resp = self.client.put(
            '/meeting/83.json',
            data="agenda=None",
            content_type="application/x-www-form-urlencoded",
            **auth_joeblow)

        self.assertEqual(resp.status_code, 403)
        self.assertNotEqual(mtg83.agenda, None)