def getRuleSetByUpdate(request, updateID): """This method is called when the url /ruleset/byUpdate/ is called. It fetches ruleset objects based on its update ID and sends them to the render. """ logger = logging.getLogger(__name__) # Spool up context. context = {} context['ismain'] = True # We fetch the update object in question. try: update = Update.objects.get(id=updateID) except Update.DoesNotExist: logger.warning("Page request /rules/ could not be resolved, objects not found.") raise Http404 try: # We need to know how many rulesets there are total. context['itemcount'] = update.ruleSets.count() # Get all rulesets belonging to the update. context['ruleset_list'] = update.ruleSets.order_by('name').all() except RuleSet.DoesNotExist: logger.warning("Page request /rules/ could not be resolved, objects not found.") raise Http404 # Process the objects before we give them to the template. context['ruleset_list'] = ruleSetsToTemplate(context['ruleset_list']) return render(request, 'ruleset/ruleSetListItems.tpl', context)
def getRuleSetChildren(request,ruleSetID): """This method is called when the url /ruleset/children/ is called. It fetches the children of a ruleset object and sends them to the render. """ logger = logging.getLogger(__name__) # Spool up context. context = {} context['ismain'] = False try: # We need to know how many rulesets there are total. context['itemcount'] = RuleSet.objects.count() #Get the parent ruleset. parent = RuleSet.objects.get(id=ruleSetID) # Get all ruleset children. context['ruleset_list'] = RuleSet.objects.filter(parent=parent).order_by('name') except RuleSet.DoesNotExist: logger.warning("Page request /rules/ could not be resolved, objects not found.") raise Http404 # Process the objects before we give them to the template. context['ruleset_list'] = ruleSetsToTemplate(context['ruleset_list']) return render(request, 'ruleset/ruleSetListItems.tpl', context)
def getRuleSetChildren(request, ruleSetID): """This method is called when the url /ruleset/children/ is called. It fetches the children of a ruleset object and sends them to the render. """ logger = logging.getLogger(__name__) # Spool up context. context = {} context['ismain'] = False try: # We need to know how many rulesets there are total. context['itemcount'] = RuleSet.objects.count() #Get the parent ruleset. parent = RuleSet.objects.get(id=ruleSetID) # Get all ruleset children. context['ruleset_list'] = RuleSet.objects.filter( parent=parent).order_by('name') except RuleSet.DoesNotExist: logger.warning( "Page request /rules/ could not be resolved, objects not found.") raise Http404 # Process the objects before we give them to the template. context['ruleset_list'] = ruleSetsToTemplate(context['ruleset_list']) return render(request, 'ruleset/ruleSetListItems.tpl', context)
def getRuleSetByUpdate(request, updateID): """This method is called when the url /ruleset/byUpdate/ is called. It fetches ruleset objects based on its update ID and sends them to the render. """ logger = logging.getLogger(__name__) # Spool up context. context = {} context['ismain'] = True # We fetch the update object in question. try: update = Update.objects.get(id=updateID) except Update.DoesNotExist: logger.warning( "Page request /rules/ could not be resolved, objects not found.") raise Http404 try: # We need to know how many rulesets there are total. context['itemcount'] = update.ruleSets.count() # Get all rulesets belonging to the update. context['ruleset_list'] = update.ruleSets.order_by('name').all() except RuleSet.DoesNotExist: logger.warning( "Page request /rules/ could not be resolved, objects not found.") raise Http404 # Process the objects before we give them to the template. context['ruleset_list'] = ruleSetsToTemplate(context['ruleset_list']) return render(request, 'ruleset/ruleSetListItems.tpl', context)