コード例 #1
0

def list_details(request, proj_id):
    '''Obtain details (description, slices, users) for a given project'''
    project = get_object_or_404(Project, id=proj_id)
    return simple.direct_to_template(
        request,
        template=TEMPLATE_PATH + "/list_details.html",
        extra_context={"project": project},
    )


@require_objs_permissions_for_view(
    perm_names=["can_delete_slices"],
    permittee_func=get_user_from_req,
    target_func=get_queryset(Project, "proj_id"),
    methods=["GET", "POST"],
)
@require_objs_permissions_for_view(
    perm_names=["can_delete_project"],
    permittee_func=get_user_from_req,
    target_func=get_queryset(Project, "proj_id"),
    methods=["GET", "POST"],
)
def delete(request, proj_id):
    '''Delete the project'''
    project = get_object_or_404(Project, id=proj_id)
    if request.method == "POST":
        try:
            for s in project.slice_set.all():
                s.stop(request.user)
コード例 #2
0
ファイル: views.py プロジェクト: HalasNet/felix
        template_object_name="project",
    )

def list_details(request, proj_id):
	'''Obtain details (description, slices, users) for a given project'''
 	project = get_object_or_404(Project, id=proj_id)
	return simple.direct_to_template(
		request,
		template=TEMPLATE_PATH+"/list_details.html",
		extra_context={"project": project},
	)

@require_objs_permissions_for_view(
    perm_names=["can_delete_slices"],
    permittee_func=get_user_from_req,
    target_func=get_queryset(Project, "proj_id"),
    methods=["GET", "POST"],
)
@require_objs_permissions_for_view(
    perm_names=["can_delete_project"],
    permittee_func=get_user_from_req,
    target_func=get_queryset(Project, "proj_id"),
    methods=["GET", "POST"],
)
def delete(request, proj_id):
    '''Delete the project'''
    project = get_object_or_404(Project, id=proj_id)
    if request.method == "POST":
        try:
            for s in project.slice_set.all():
                s.stop(request.user)
コード例 #3
0
@author: jnaous
'''
from django.http import HttpResponse, HttpResponseRedirect
from django.views.generic import create_update
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404
from expedient.common.permissions.utils import get_queryset_from_class
from expedient.common.permissions.utils import get_user_from_req, get_queryset
from expedient.common.permissions.shortcuts import give_permission_to
from expedient.common.permissions.decorators import require_objs_permissions_for_view
from models import PermissionTestClass

@require_objs_permissions_for_view(
    ["can_get_x2", "can_read_val"],
    get_user_from_req,
    get_queryset(PermissionTestClass, "obj_id"),
)
def test_view_x2(request, obj_id=None):
    obj = get_object_or_404(PermissionTestClass, pk=obj_id)
    return HttpResponse("%s" % obj.get_val_x2())

@require_objs_permissions_for_view(
    ["can_add"],
    get_user_from_req,
    get_queryset_from_class(PermissionTestClass),
    ["POST"],
)
def test_view_create(request):
    return create_update.create_object(
        request, PermissionTestClass,
        template_name="permissions/empty.html",
コード例 #4
0
logger = logging.getLogger("OpenFlow plugin views")
MAX_ALLOWED_VLAN_RANGE = 20


@require_objs_permissions_for_view(
    perm_names=["can_add_aggregate"],
    permittee_func=get_user_from_req,
    target_func=get_queryset_from_class(Aggregate),
    methods=["POST", "GET"])
def aggregate_create(request):
    return aggregate_crud(request)


@require_objs_permissions_for_view(perm_names=["can_edit_aggregate"],
                                   permittee_func=get_user_from_req,
                                   target_func=get_queryset(
                                       OpenFlowAggregate, "agg_id"),
                                   methods=["POST", "GET"])
def aggregate_edit(request, agg_id):
    return aggregate_crud(request, agg_id=agg_id)


def aggregate_crud(request, agg_id=None):
    '''
    Create/update an OpenFlow Aggregate.
    '''
    if agg_id != None:
        aggregate = get_object_or_404(OpenFlowAggregate, pk=agg_id)
        client = aggregate.client
    else:
        aggregate = None
        client = None
コード例 #5
0
ファイル: views.py プロジェクト: fp7-alien/C-BAS
logger = logging.getLogger("OpenFlow plugin views")
MAX_ALLOWED_VLAN_RANGE = 20

@require_objs_permissions_for_view(
    perm_names=["can_add_aggregate"],
    permittee_func=get_user_from_req,
    target_func=get_queryset_from_class(Aggregate),
    methods=["POST", "GET"])
def aggregate_create(request):
    return aggregate_crud(request)

@require_objs_permissions_for_view(
    perm_names=["can_edit_aggregate"],
    permittee_func=get_user_from_req,
    target_func=get_queryset(OpenFlowAggregate, "agg_id"),
    methods=["POST", "GET"])
def aggregate_edit(request, agg_id):
    return aggregate_crud(request, agg_id=agg_id)

def aggregate_crud(request, agg_id=None):
    '''
    Create/update an OpenFlow Aggregate.
    '''
    if agg_id != None:
        aggregate = get_object_or_404(OpenFlowAggregate, pk=agg_id)
        client = aggregate.client
    else:
        aggregate = None
        client = None
        
コード例 #6
0
'''
from django.http import HttpResponse, HttpResponseRedirect
from django.views.generic import create_update
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404
from expedient.common.permissions.utils import get_queryset_from_class
from expedient.common.permissions.utils import get_user_from_req, get_queryset
from expedient.common.permissions.shortcuts import give_permission_to
from expedient.common.permissions.decorators import require_objs_permissions_for_view
from models import PermissionTestClass


@require_objs_permissions_for_view(
    ["can_get_x2", "can_read_val"],
    get_user_from_req,
    get_queryset(PermissionTestClass, "obj_id"),
)
def test_view_x2(request, obj_id=None):
    obj = get_object_or_404(PermissionTestClass, pk=obj_id)
    return HttpResponse("%s" % obj.get_val_x2())


@require_objs_permissions_for_view(
    ["can_add"],
    get_user_from_req,
    get_queryset_from_class(PermissionTestClass),
    ["POST"],
)
def test_view_create(request):
    return create_update.create_object(
        request,