当前位置: 首页>>代码示例>>Python>>正文


Python models.Unit类代码示例

本文整理汇总了Python中coredata.models.Unit的典型用法代码示例。如果您正苦于以下问题:Python Unit类的具体用法?Python Unit怎么用?Python Unit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Unit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: student_appointments

def student_appointments(request, userid):
    student = get_object_or_404(Person, find_userid_or_emplid(userid))
    appointments = RAAppointment.objects.filter(person=student, unit__in=Unit.sub_units(request.units), deleted=False).order_by("-created_at")
    grads = GradStudent.objects.filter(person=student, program__unit__in=Unit.sub_units(request.units))
    context = {'appointments': appointments, 'student': student,
               'grads': grads}
    return render(request, 'ra/student_appointments.html', context)
开发者ID:tedkirkpatrick,项目名称:coursys,代码行数:7,代码来源:views.py

示例2: add_booking

def add_booking(request, location_slug, from_index=0):
    location = get_object_or_404(Location, slug=location_slug, unit__in=Unit.sub_units(request.units))
    editor = get_object_or_404(Person, userid=request.user.username)
    if request.method == 'POST':
        form = BookingRecordForm(request.POST)
        if form.is_valid():
            booking = form.save(commit=False)
            booking.location = location
            booking.save(editor=editor)
            location.mark_conflicts()
            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Booking was created')
            l = LogEntry(userid=request.user.username,
                         description="Added booking %s for location %s" % (booking, location),
                         related_object=booking)
            l.save()
            if from_index == '1':
                return HttpResponseRedirect(reverse('space:index'))
            return view_location(request, location_slug)

        else:
            form.fields['start_time'].help_text = "Any previous bookings without an end time will also get its " \
                                                  "end time set to this."
    else:
        form = BookingRecordForm()
        form.fields['start_time'].help_text = "Any previous bookings without an end time will also get its " \
                                              "end time set to this."

    return render(request, 'space/new_booking.html', {'form': form, 'location': location, 'from_index': from_index})
开发者ID:sfu-fas,项目名称:coursys,代码行数:30,代码来源:views.py

示例3: person_info

def person_info(request):
    """
    Get more info about this person, for AJAX updates on new RA form
    """
    result = {'programs': []}
    emplid = request.GET.get('emplid', None)
    if not emplid or not emplid.isdigit() or len(emplid) != 9:
        pass
    else:
        programs = []
        
        # GradPrograms
        emplid = request.GET['emplid']
        grads = GradStudent.objects.filter(person__emplid=emplid, program__unit__in=Unit.sub_units(request.units))
        for gs in grads:
            pdata = {
                     'program': gs.program.label,
                     'unit': gs.program.unit.name,
                     'status': gs.get_current_status_display(),
                     }
            programs.append(pdata)

        result['programs'] = programs
        
        # other SIMS info
        try:
            otherinfo = more_personal_info(emplid, needed=['citizen', 'visa'])
            result.update(otherinfo)
        except SIMSProblem, e:
            result['error'] = e.message
开发者ID:tedkirkpatrick,项目名称:coursys,代码行数:30,代码来源:views.py

示例4: download_locations

def download_locations(request):
    units = Unit.sub_units(request.units)
    locations = Location.objects.visible(units).select_related('unit', 'room_type')\
        .prefetch_related('safety_items', 'bookings', 'bookings__person')
    response = HttpResponse(content_type='text/csv')

    response['Content-Disposition'] = 'inline; filename="locations-%s.csv"' % \
                                      (datetime.datetime.now().strftime('%Y%m%d'))
    writer = csv.writer(response)
    writer.writerow(['Unit', 'Campus', 'Building', 'Floor', 'Room Number', 'Square Meters', 'Room Type Description',
                     'Room Type Code', 'COU Code Description', 'Space Factor', 'COU Code Value', 'Infrastructure',
                     'Room Capacity', 'Category', 'Occupancy', 'Own/Leased', 'Safety Infrastructure Items', 'Comments',
                     'Current Booking', 'Active Grad Student(s)'])
    for l in locations:
        bookings = l.get_current_bookings()
        grad_count = None
        if bookings:
            grad_count = 0
            for b in bookings:
                booker = b.person
                grad_count += Supervisor.objects.filter(supervisor=booker, removed=False,
                                                        student__current_status='ACTI').count()

        writer.writerow([l.unit.name, l.get_campus_display(), l.get_building_display(), l.floor, l.room_number,
                         l.square_meters, l.room_type.long_description, l.room_type.code,
                         l.room_type.COU_code_description, l.room_type.space_factor, l.room_type.COU_code_value,
                         l.get_infrastructure_display(), l.room_capacity, l.get_category_display(), l.occupancy_count,
                         l.get_own_or_lease_display(), l.safety_items_display(), l.comments,
                         l.get_current_bookings_str(), grad_count])
    return response
开发者ID:sfu-fas,项目名称:coursys,代码行数:30,代码来源:views.py

示例5: config_display

 def config_display(cls, units):
     committees = list(cls.all_config_fields(Unit.sub_units(units), 'committees'))
     unit_lookup = CommitteeMemberHandler._unit_lookup()
     for c in committees:
         c[3] = unit_lookup[c[3]]
     context = Context({'committees': committees})
     return cls.DISPLAY_TEMPLATE.render(context)
开发者ID:sfu-fas,项目名称:coursys,代码行数:7,代码来源:info.py

示例6: download_booking_attachment

def download_booking_attachment(request, booking_slug, attachment_id):
    booking = get_object_or_404(BookingRecord, slug=booking_slug, location__unit__in=Unit.sub_units(request.units))
    attachment = get_object_or_404(BookingRecordAttachment, booking_record=booking, pk=attachment_id)
    filename = attachment.contents.name.rsplit('/')[-1]
    resp = StreamingHttpResponse(attachment.contents.chunks(), content_type=attachment.mediatype)
    resp['Content-Disposition'] = 'attachment; filename="' + filename + '"'
    resp['Content-Length'] = attachment.contents.size
    return resp
开发者ID:sfu-fas,项目名称:coursys,代码行数:8,代码来源:views.py

示例7: __init__

 def __init__(self, request, *args, **kwargs):
     super(AssetChangeForm, self).__init__(*args, **kwargs)
     #  The following two lines look stupid, but they are not.  request.units contains a set of units.
     #  in order to be used this way, we need an actual queryset.
     #
     #  In this case, we also include subunits.  If you manage assets for a parent unit, chances are you may be
     #  adding/removing them for events in your children units.
     unit_ids = [unit.id for unit in Unit.sub_units(request.units)]
     units = Unit.objects.filter(id__in=unit_ids)
开发者ID:sfu-fas,项目名称:coursys,代码行数:9,代码来源:forms.py

示例8: create_true_core

def create_true_core():
    """
    Just enough data to bootstrap a minimal environment.
    """
    import_semester_info(dry_run=False, verbose=False, long_long_ago=True, bootstrap=True)
    p = find_person('ggbaker')
    p.emplid = '200000100'
    p.save()
    u = Unit(label='UNIV', name='Simon Fraser University')
    u.save()
    r = Role(person=p, role='SYSA', unit=u)
    r.save()

    return itertools.chain(
        Semester.objects.filter(name__gt=SEMESTER_CUTOFF),
        Person.objects.filter(userid='ggbaker'),
        Unit.objects.all(),
        Role.objects.all(),
    )
开发者ID:tedkirkpatrick,项目名称:coursys,代码行数:19,代码来源:devtest_importer.py

示例9: get_unit

def get_unit(acad_org, create=False):
    """
    Get the corresponding Unit
    """
    # there are some inconsistent acad_org values: normalize.
    if acad_org == 'GERON':
        acad_org = 'GERONTOL'
    elif acad_org == 'GEOG':
        acad_org = 'GEOGRAPH'
    elif acad_org == 'BUS':
        acad_org = 'BUS ADMIN'
    elif acad_org == 'HUM':
        acad_org = 'HUMANITIES'
    elif acad_org == 'EVSC':
        acad_org = 'ENVIRO SCI'

    try:
        unit = Unit.objects.get(acad_org=acad_org)
    except Unit.DoesNotExist:
        db = SIMSConn()
        db.execute("SELECT descrformal FROM ps_acad_org_tbl "
                   "WHERE eff_status='A' and acad_org=%s", (acad_org,))
        
        name, = db.fetchone()
        if acad_org == 'COMP SCI': # for test/demo imports
            label = 'CMPT'
        elif acad_org == 'ENG SCI': # for test/demo imports
            label = 'ENSC'
        elif acad_org == 'ENVIRONMEN': # for test/demo imports
            label = 'FENV'
        elif acad_org == 'DEAN GRAD': # for test/demo imports
            label = 'GRAD'
        else:
            label = acad_org[:4].strip()

        if create:
            unit = Unit(acad_org=acad_org, label=label, name=name, parent=None)
            unit.save()
        else:
            raise KeyError("Unknown unit: acad_org=%s, label~=%s, name~=%s." % (acad_org, label, name))

    return unit
开发者ID:sfu-fas,项目名称:coursys,代码行数:42,代码来源:importer.py

示例10: delete_unit_role

def delete_unit_role(request, role_id):
    role = get_object_or_404(Role, pk=role_id, unit__in=Unit.sub_units(request.units), role__in=UNIT_ROLES)
    messages.success(request, 'Deleted role %s for %s.' % (role.get_role_display(), role.person.name()))
    #LOG EVENT#
    l = LogEntry(userid=request.user.username,
          description=("deleted role: %s for %s in %s") % (role.get_role_display(), role.person.name(), role.unit),
          related_object=role.person)
    l.save()
    
    role.delete()
    return HttpResponseRedirect(reverse(unit_role_list))
开发者ID:avacariu,项目名称:coursys,代码行数:11,代码来源:views.py

示例11: create_test_offering

def create_test_offering():
    """
    Create a CourseOffering (and related stuff) that can be used in tests with no fixtures
    """
    s = create_fake_semester('1144')
    u = Unit(label='BABL', name="Department of Babbling")
    u.save()
    o = CourseOffering(subject='BABL', number='123', section='F104', semester=s, component='LEC', owner=u,
                       title='Babbling for Baferad Ferzizzles', enrl_cap=100, enrl_tot=5, wait_tot=0)
    o.save()

    i = Person(first_name='Insley', last_name='Instructorberg', emplid=20000009, userid='instr')
    i.save()
    s = Person(first_name='Stanley', last_name='Studentson', emplid=20000010, userid='student')
    s.save()

    Member(offering=o, person=i, role='INST').save()
    Member(offering=o, person=s, role='STUD').save()

    return o
开发者ID:avacariu,项目名称:coursys,代码行数:20,代码来源:testing.py

示例12: delete_room_safety_item

def delete_room_safety_item(request, safety_item_slug):
    safety_item = get_object_or_404(RoomSafetyItem, unit__in=Unit.sub_units(request.units), slug=safety_item_slug)
    if request.method == 'POST':
        safety_item.delete()
        messages.add_message(request,
                             messages.SUCCESS,
                             'Safety item was deleted')
        l = LogEntry(userid=request.user.username,
                     description="Deleted safety item %s" % safety_item,
                     related_object=safety_item)
        l.save()
        return HttpResponseRedirect(reverse('space:manage_safety_items'))
开发者ID:sfu-fas,项目名称:coursys,代码行数:12,代码来源:views.py

示例13: delete_booking_attachment

def delete_booking_attachment(request, booking_slug, attachment_id):
    booking = get_object_or_404(BookingRecord, slug=booking_slug, location__unit__in=Unit.sub_units(request.units))
    attachment = get_object_or_404(BookingRecordAttachment, booking_record=booking, pk=attachment_id)
    attachment.hide()
    messages.add_message(request,
                         messages.SUCCESS,
                         'Attachment was deleted')
    l = LogEntry(userid=request.user.username,
                 description="Deleted attachment in booking %s" % booking,
                 related_object=attachment)
    l.save()
    return HttpResponseRedirect(reverse('space:view_booking', kwargs={'booking_slug': booking.slug}))
开发者ID:sfu-fas,项目名称:coursys,代码行数:12,代码来源:views.py

示例14: delete_location

def delete_location(request, location_id):
    location = get_object_or_404(Location, pk=location_id, unit__in=Unit.sub_units(request.units))
    if request.method == 'POST':
        location.hidden = True
        location.save()
        messages.add_message(request,
                             messages.SUCCESS,
                             'Location was deleted')
        l = LogEntry(userid=request.user.username,
                     description="Deleted location %s" % location,
                     related_object=location)
        l.save()
    return HttpResponseRedirect(reverse('space:index'))
开发者ID:sfu-fas,项目名称:coursys,代码行数:13,代码来源:views.py

示例15: delete_roomtype

def delete_roomtype(request, roomtype_id):
    roomtype = get_object_or_404(RoomType, pk=roomtype_id, unit__in=Unit.sub_units(request.units))
    if request.method == 'POST':
        roomtype.hidden = True
        roomtype.save()
        messages.add_message(request,
                             messages.SUCCESS,
                             'Room type was deleted')
        l = LogEntry(userid=request.user.username,
                     description="Deleted roomtype %s" % roomtype,
                     related_object=roomtype)
        l.save()
    return HttpResponseRedirect(reverse('space:list_roomtypes'))
开发者ID:sfu-fas,项目名称:coursys,代码行数:13,代码来源:views.py


注:本文中的coredata.models.Unit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。