def showGroupDNISettings(request, slug_group): ''' Muestra la configuracion de DNI de los integrantes de un grupo ''' saveViewsLog(request, "apps.groups_app.views.groupDNISettings") try: g = Groups.objects.get_group(slug=slug_group) _user_rel = getRelUserGroup(request.user, g) members_dni = DNI_permissions.objects.filter(id_group=g) users_dni = [] for m in members_dni: users_dni.append(m.id_user) members = rel_user_group.objects.filter( id_group=g, is_member=True).exclude(id_user__in=users_dni) ctx = { "group": g, "rel_user": _user_rel, 'members': members, 'members_dni': members_dni, "breadcrumb": _("Config. DNI") } return render_to_response('groups/templates/showGroupDNI.html', ctx, context_instance=RequestContext(request)) except groups.DoesNotExist: return HttpResponseRedirect('/groups/')
def editInfoGroup(request, slug_group): ''' Muestra la configuracion de un grupo ''' saveViewsLog(request, "apps.groups_app.views.groupInfoSettings") g = Groups.objects.get_group(slug=slug_group) _user_rel = getRelUserGroup(request.user, g) if _user_rel.is_admin and _user_rel.is_active: message = False if request.method == "POST": form = newGroupForm(request.POST) if form.is_valid(): g.name = form.cleaned_data['name'] g.description = form.cleaned_data['description'] g.save() message = "Los datos del grupo han sido actualizados" else: message = "Hubo un error en los datos del grupo. Intenta de nuevo." form = newGroupForm(initial={ "name": g.name, "description": g.description }) ctx = { "group": g, "rel_user": _user_rel, "form": form, "message": message, "breadcrumb": _(u"Editar información") } return render_to_response('groups/templates/editInfoGroup.html', ctx, context_instance=RequestContext(request)) else: return HttpResponseRedirect('/groups/' + str(g.slug))
def showHomeGroup(request, slug_group): '''Carga el menú de un grupo''' g = Groups.objects.get_group(slug=slug_group) _user = getRelUserGroup(request.user, g) is_org_admin = g.organization.has_user_role(request.user, "is_admin") if is_org_admin or _user: if is_org_admin or _user.is_active: return HttpResponseRedirect( reverse("show_folder", args=(slug_group, ))) raise Http404
def showCalendarGroup(request, slug_group): saveViewsLog(request, "apps.groups_app.views.showCalendarGroup") g = Groups.objects.get_group(slug=slug_group) _user = getRelUserGroup(request.user, g) is_org_admin = g.organization.has_user_role(request.user, "is_admin") if is_org_admin or _user: if is_org_admin or _user.is_active: _reunions = reunions.objects.filter( id_group=g).order_by("date_reunion") ctx = { "group": g, "rel_user": _user, "reunions": _reunions, "breadcrumb": _("Agenda de reuniones") } return render_to_response("groups/templates/calendar.html", ctx, context_instance=RequestContext(request)) return HttpResponseRedirect('/groups/#you-are-not-active') return HttpResponseRedirect('/groups/#error-view-group')
def showTeamGroup(request, slug_group): saveViewsLog(request, "apps.groups_app.views.showTeamGroup") try: u_selected = None if request.method == "GET": u = str(request.GET['u']) u_selected = User.objects.get(username=u).id except: u_selected = None g = Groups.objects.get_group(slug=slug_group) user_is_org_admin = g.organization.has_user_role(request.user, "is_admin") _user_rel = getRelUserGroup(request.user, g.id) if _user_rel or user_is_org_admin: if user_is_org_admin or _user_rel.is_active: members = rel_user_group.objects.filter(id_group=g.id).order_by( "-id_user__is_active", "id_user__username") is_m = _user_rel.is_member if ( _user_rel and _user_rel.is_member) else user_is_org_admin is_s = _user_rel.is_secretary if ( _user_rel and _user_rel.is_secretary) else user_is_org_admin ctx = { "user_is_org_admin": user_is_org_admin, "group": g, "rel_user": _user_rel, "is_member": is_m, "is_secretary": is_s, "members": members, "user_selected": u_selected, "breadcrumb": _("Equipo de trabajo") } return render(request, 'groups/templates/team.html', ctx) else: raise Http404 return HttpResponseRedirect('/groups/' + str(g.slug) + "#not-active") else: raise Http404 return render("groups/templates/team.html", ctx)
def showFolderGroup(request, slug_group): saveViewsLog(request, "apps.groups_app.views.showFolderGroup") g = Groups.objects.get_group(slug=slug_group) _user = getRelUserGroup(request.user, g) is_org_admin = g.organization.has_user_role(request.user, "is_admin") if is_org_admin or _user: if is_org_admin or _user.is_active: minutes_group = minutes.objects.filter( id_group=g, is_valid=True).order_by("-date_created") m = list() for _minutes in minutes_group: m.append({ "minutes": _minutes, "rol": getRolUserMinutes(request.user, g, id_minutes=_minutes) }) if request.method == "GET": try: # Say if the user can upload minutes no_redactor = request.GET['no_redactor'] except Exception: no_redactor = 0 ctx = { "group": g, "rel_user": _user, "minutes": m, 'no_redactor': no_redactor, "breadcrumb": _("Folder de actas") } return render_to_response("groups/templates/folder.html", ctx, context_instance=RequestContext(request)) return HttpResponseRedirect('/groups/#you-are-not-active') else: raise Http404
def rolesForMinutes(request, slug_group, id_reunion): '''[DEPRECATED 07/07/14] return the board to set the roles for a new Minutes''' saveViewsLog(request, "apps.groups_app.minutes.rolesForMinutes") try: if id_reunion: reunion = reunions.objects.get(id=id_reunion).id else: reunion = "" except reunions.DoesNotExist: reunion = "" g = Groups.objects.get_group(slug=slug_group) _user_rel = getRelUserGroup(request.user, g.id) is_org_admin = g.organization.has_user_role(request.user, "is_admin") if is_org_admin or _user_rel.is_secretary and _user_rel.is_active: members = rel_user_group.objects.filter( id_group=g, is_member=True).order_by("-is_active") _members = list() for m in members: try: rel = rol_user_minutes.objects.get(id_group=g, id_user=m.id_user, id_minutes=None, is_active=False) except rol_user_minutes.DoesNotExist: rel = None except Exception, e: rel = None _members.append({"member": m, "rol": rel}) try: _secretary = rol_user_minutes.objects.get( id_group=g, is_active=False, is_secretary=True).id_user.id except rol_user_minutes.DoesNotExist: _secretary = None except Exception: _secretary = None try: _president = rol_user_minutes.objects.get( id_group=g, is_active=False, is_president=True).id_user.id except rol_user_minutes.DoesNotExist: _president = None except Exception: _president = None # get last template used try: template = minutes.objects.filter( id_group=g, is_valid=True).order_by("-code")[0] template = template.id_template.slug except Exception: template = "" try: rel = rel_group_dni.objects.get(id_group=g) if rel.show_dni == True: show_dni = True else: show_dni = False except rel_group_dni.DoesNotExist: show_dni = False # print show_dni ctx = { "group": g, "template": template, "rel_user": _user_rel, "members": _members, "id_reunion": reunion, "secretary": _secretary, "president": _president, "show_dni": show_dni, "breadcrumb": _("Definir roles") } return render_to_response('groups/templates/rolesForMinutes.html', ctx, context_instance=RequestContext(request))
def showMinuteGroup(request, slug_group, minutes_code): '''Muestra toda la informacion de un Acta dentro de un grupo (minutes)''' saveViewsLog(request, "apps.groups_app.views.showMinuteGroup") group = Groups.objects.get_group(slug=slug_group) if not group: return HttpResponseRedirect('/groups/#error-there-is-not-the-group') is_org_admin = group.organization.has_user_role(request.user, "is_admin") if not (isMemberOfGroup(request.user, group) or is_org_admin): raise Http404 # return HttpResponseRedirect('/groups/#error-its-not-your-group') else: minutes_current = group.get_minutes_by_code(code=minutes_code) rel_group = getRelUserGroup(request.user, group) rol = getRolUserMinutes(request.user, group, id_minutes=minutes_current) rol_is_approver = False rel_group_is_secretary = False if rol and rel_group: rol_is_approver = rol.is_approver rel_group_is_secretary = rel_group.is_secretary if is_org_admin or (rel_group and rol_is_approver or rel_group_is_secretary or rel_group.is_secretary or rel_group.is_admin or minutes_current.is_minute_full_signed()): if not minutes_current: return HttpResponseRedirect( '/groups/' + slug_group + '/#error-there-is-not-that-minutes') ######## <ASISTENTES> ######### m_assistance, m_no_assistance = getMembersAssistance( group, minutes_current) ######## <ASISTENTES> ######### ######## <ATTENDING> ######### space_to_approve = False my_attending = False sign = getRelUserMinutesSigned(request.user, minutes_current) if sign: space_to_approve = True my_attending = True if sign.is_signed_approved == 0 else False ######## </ATTENDING> ######### ######## <APPROVER LISTS> ######### try: # missing_approved_list = rel_user_minutes_signed.objects.filter(id_minutes=minutes_current) missing_approved_list = group.rol_user_minutes_id_group.filter( id_minutes=minutes_current, is_active=True, is_approver=True) # missing_approved_list = 0 if len(missing_approved_list) == 0 else missing_approved_list except rel_user_minutes_signed.DoesNotExist: print "NO HAY rel_user_minutes_assistance missing_approved_list" except Exception, e: print "error,", e ######## </APPROVER LISTS> ######### ######## <PREV and NEXT> ######### prev, next = getPrevNextOfGroup(group, minutes_current) ######## </PREV and NEXT> ######### annon = annotations.objects.filter( id_minutes=minutes_current).order_by("-date_joined") minutes_version = getMinutesVersions(minutes_current) is_s = False if rel_group: is_s = rel_group.is_secretary ctx = { "group": group, "minutes": minutes_current, "prev": prev, "next": next, "rel_user": rel_group, "is_secretary": is_s, "m_assistance": m_assistance, "m_no_assistance": m_no_assistance, "url_minute": request.get_full_path(), "minute_template": minutes_current.render_as_string(), "template": minutes_current.id_template.slug, "space_to_approve": space_to_approve, "my_attending": my_attending, "commission_approving": missing_approved_list, "annotations": annon, "minutes_version": minutes_version, "is_form": 0, "breadcrumb": _("Acta ") + minutes_code } else: