def create(request): acc = acc_for_user(request.user) my_meetings_sco = get_sco(acc, _user_meeting_folder(request, acc)) template_sco_id = acc.default_template_sco_id if not template_sco_id: template_sco_id = settings.DEFAULT_TEMPLATE_SCO room = Room(creator=request.user, folder_sco=my_meetings_sco, source_sco=get_sco(acc, template_sco_id)) what = "Create" title = "Create a new room" if request.method == 'POST': form = CreateRoomForm(request.POST, instance=room) _init_update_form(request, form, acc, my_meetings_sco) if form.is_valid(): _update_room(request, room, form.cleaned_data) room = form.save() return redirect_to("/rooms#%d" % room.id) else: form = CreateRoomForm(instance=room) _init_update_form(request, form, acc, my_meetings_sco) return respond_to(request, {'text/html': 'apps/room/create.html'}, {'form': form, 'formtitle': title, 'cancelurl': '/rooms', 'cancelname': 'Cancel', 'submitname': '%s Room' % what})
def untag(request, rid, tag): room = get_object_or_404(Room, pk=rid) new_tags = [] for t in Tag.objects.get_for_object(room): if t.name != tag: new_tags.append(t.name) Tag.objects.update_tags(room, ' '.join(new_tags)) return redirect_to("/room/%d/tag" % room.id)
def untag(request,rid,tag): ar = get_object_or_404(Archive,pk=rid) new_tags = [] for t in Tag.objects.get_for_object(ar): if t.name != tag: new_tags.append(t.name) Tag.objects.update_tags(ar, ' '.join(new_tags)) return redirect_to("/archive/%d/tag" % ar.id)
def update(request, id): room = get_object_or_404(Room, pk=id) acc = room.sco.acc what = "Update" title = "Modify %s" % room.name if request.method == 'POST': form = ModifyRoomForm(request.POST, instance=room) _init_update_form(request, form, acc, room.folder_sco) if form.is_valid(): _update_room(request, room, form.cleaned_data) room = form.save() return redirect_to("/rooms#%d" % room.id) else: form = ModifyRoomForm(instance=room) _init_update_form(request, form, acc, room.folder_sco) return respond_to(request, {'text/html': 'apps/room/update.html'}, {'form': form, 'formtitle': title, 'cancelurl': '/rooms#%d' % room.id, 'cancelname': 'Cancel', 'submitname': '%s Room' % what})
def delete(request, id): room = get_object_or_404(Room, pk=id) if request.method == 'POST': form = DeleteRoomForm(request.POST) if form.is_valid(): with ac_api_client(room.sco.acc) as api: api.request('sco-delete', {'sco-id': room.sco.sco_id}, raise_error=False) #clear_acl(room) #room.sco.delete() #if room.folder_sco is not None: #room.folder_sco.delete() #if room.deleted_sco is not None: #room.deleted_sco.delete() room.delete() return redirect_to("/rooms") else: form = DeleteRoomForm() return respond_to(request, {'text/html': 'edit.html'}, {'form': form, 'formtitle': 'Delete %s' % room.name, 'cancelurl': '/rooms', 'cancelname': 'Cancel', 'submitname': 'Delete Room'})
def unlock(request, id): room = get_object_or_404(Room, pk=id) room.unlock() return redirect_to("/rooms#%d" % room.id)
def publish_sco(request,rid,sco_id): room = get_object_or_404(Room,pk=rid) acc = room.sco.sco_id ar = publish_archive(room,sco_id) return redirect_to("/room/%d/recordings#%d" % (rid,ar.sco.sco_id))
def welcome(request): if not request.user.is_anonymous(): return redirect_to('/rooms') else: return redirect_to('/accounts/login')
def accounts_login_federated(request): if request.user.is_authenticated(): profile, created = UserProfile.objects.get_or_create(user=request.user) if created: profile.identifier = request.user.username profile.user = request.user profile.save() update = False fn = meta1(request,'givenName') ln = meta1(request,'sn') cn = meta1(request,'cn') if not cn: cn = meta1(request,'displayName') logging.debug("cn=%s" % cn) if not cn and fn and ln: cn = "%s %s" % (fn,ln) if not cn: cn = profile.identifier mail = meta1(request,'mail') idp = meta1(request,'Shib-Identity-Provider') for attrib_name, meta_value in (('display_name',cn),('email',mail),('idp',idp)): attrib_value = getattr(profile, attrib_name) if meta_value and not attrib_value: setattr(profile,attrib_name,meta_value) update = True if request.user.password == "": request.user.password = "******" update = True if update: request.user.save() # Allow auto_now to kick in for the lastupdated field #profile.lastupdated = datetime.datetime.now() profile.save() next = request.session.get("after_login_redirect", None) if not next and request.GET.has_key('next'): next = request.GET['next'] else: next = settings.DEFAULT_URL acc = acc_for_user(request.user) with ac_api_client(request) as api: # make sure the principal is created before shooting off principal = api.find_or_create_principal("login", request.user.username, "user", {'type': "user", 'has-children': "0", 'first-name':fn, 'last-name':ln, 'email':mail, 'send-email': 0, 'login':request.user.username, 'ext-login':request.user.username}) #co_import_from_request(request) import_user_rooms(acc, api, request.user) member_or_employee = _is_member_or_employee(request.user) for gn in ('live-admins','seminar-admins'): group = api.find_builtin(gn) if group: api.add_remove_member(principal.get('principal-id'),group.get('principal-id'),member_or_employee) #(lp,domain) = uid.split('@') #for a in ('student','employee','member'): # affiliation = "%s@%s" % (a,domain) # group = connect_api.find_or_create_principal('name',affiliation,'group',{'type': 'group','has-children':'1','name': affiliation}) # member = affiliation in affiliations # connect_api.add_remove_member(principal.get('principal-id'),group.get('principal-id'),member) #for e in epe: # group = connect_api.find_or_create_principal('name',e,'group',{'type': 'group','has-children':'1','name': e}) # if group: # connect_api.add_remove_member(principal.get('principal-id'),group.get('principal-id'),True) if next is not None: return redirect_to(next) else: pass return redirect_to(settings.LOGIN_URL)