Ejemplo n.º 1
0
def getEditRuleSetForm(request, ruleSetID):
	"""This method is called when the url /ruleset/getEditRuleSetForm/ is called.
	It delivers a form to the render.
	"""
	logger = logging.getLogger(__name__)
	
	context = {}
	
	# We only edit one ruleset at a time.
	try:
		#Fetch the ruleset.
		ruleSet = RuleSet.objects.get(id=ruleSetID)
		context['ruleSetID'] = ruleSet.id
		context['ruleSetName'] = ruleSet.name
		# We deliver lists of parent and child IDs so that they can be matched.
		if ruleSet.parent:
			context['ruleSetParent'] = ruleSet.parent.id
		else:
			context['ruleSetParent'] = None
		if ruleSet.childSets.count() > 0:
			context['ruleSetChildren'] = ruleSet.childSets.values_list('id', flat=True)
		else:
			context['ruleSetChildren'] = None
		# Get all the parent rulesets.
		context['ruleset_list'] = RuleSet.objects.filter(parent=None).order_by('name')
	
	except RuleSet.DoesNotExist:
		logger.warning("No RuleSet found.")
		raise Http404
	
	# Process the objects before we give them to the template.
	context['ruleset_list'] = ruleSetHierarchyListToTemplate(context['ruleset_list'], 0)
	# Send to template.
	return render(request, 'ruleset/editRuleSetForm.tpl', context)
Ejemplo n.º 2
0
def getCreateRuleSetForm(request):
	"""This method is called when the url /ruleset/getCreateRuleSetForm/ is called.
	It delivers a form to the render.
	"""
	logger = logging.getLogger(__name__)
	
	context = {}
	
	try:
		# Get all the parent rulesets.
		context['ruleset_list'] = RuleSet.objects.filter(parent=None).order_by('name')
	
	except RuleSet.DoesNotExist:
		logger.warning("No RuleSet found.")
		raise Http404
	
	# Process the objects before we give them to the template.
	context['ruleset_list'] = ruleSetHierarchyListToTemplate(context['ruleset_list'], 0)
	# Send to template.
	return render(request, 'ruleset/createRuleSetForm.tpl', context)
Ejemplo n.º 3
0
def getCreateRuleSetForm(request):
    """This method is called when the url /ruleset/getCreateRuleSetForm/ is called.
	It delivers a form to the render.
	"""
    logger = logging.getLogger(__name__)

    context = {}

    try:
        # Get all the parent rulesets.
        context['ruleset_list'] = RuleSet.objects.filter(
            parent=None).order_by('name')

    except RuleSet.DoesNotExist:
        logger.warning("No RuleSet found.")
        raise Http404

    # Process the objects before we give them to the template.
    context['ruleset_list'] = ruleSetHierarchyListToTemplate(
        context['ruleset_list'], 0)
    # Send to template.
    return render(request, 'ruleset/createRuleSetForm.tpl', context)
Ejemplo n.º 4
0
def getEditRuleSetForm(request, ruleSetID):
    """This method is called when the url /ruleset/getEditRuleSetForm/ is called.
	It delivers a form to the render.
	"""
    logger = logging.getLogger(__name__)

    context = {}

    # We only edit one ruleset at a time.
    try:
        #Fetch the ruleset.
        ruleSet = RuleSet.objects.get(id=ruleSetID)
        context['ruleSetID'] = ruleSet.id
        context['ruleSetName'] = ruleSet.name
        # We deliver lists of parent and child IDs so that they can be matched.
        if ruleSet.parent:
            context['ruleSetParent'] = ruleSet.parent.id
        else:
            context['ruleSetParent'] = None
        if ruleSet.childSets.count() > 0:
            context['ruleSetChildren'] = ruleSet.childSets.values_list(
                'id', flat=True)
        else:
            context['ruleSetChildren'] = None
        # Get all the parent rulesets.
        context['ruleset_list'] = RuleSet.objects.filter(
            parent=None).order_by('name')

    except RuleSet.DoesNotExist:
        logger.warning("No RuleSet found.")
        raise Http404

    # Process the objects before we give them to the template.
    context['ruleset_list'] = ruleSetHierarchyListToTemplate(
        context['ruleset_list'], 0)
    # Send to template.
    return render(request, 'ruleset/editRuleSetForm.tpl', context)