django.template.loader.get_template - python examples

Here are the examples of the python api django.template.loader.get_template taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

145 Examples 7

1 2 3
3 View Complete Implementation : frontend_views.py
Copyright GNU General Public License v3.0
Author : CodigoSur
    def get_response(self, request, req_context, options, content_object):
        collection = content_object
        categorizations_list = Categorization.objects.filter(category__in=collection.categories.all())
        object_list = list(set([cat.content_object for cat in categorizations_list]))

        paginator = NamePaginator(object_list, on="name", per_page=self.items_per_page)
        page = cyclope.utils.get_page(paginator, request)

        req_context.update({'object_list': page.object_list,
                            'page': page,
                            'collection': collection
                            })
        t = loader.get_template(self.template)
        return t.render(req_context)

3 View Complete Implementation : utility_tags.py
Copyright MIT License
Author : PacktPublishing
    def render(self, context):
        try:
            # Loading the template and rendering it
            included_template = self.template_name.resolve(context)
            if isinstance(included_template, str):
                included_template = get_template(included_template)
            rendered_template = included_template.render(context)
        except (template.TemplateDoesNotExist,
                template.VariableDoesNotExist,
                AttributeError):
            rendered_template = ""
        return rendered_template

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def possible_lm(request):

    t = loader.get_template('possible_lm.html')
    events=PossibleLM.objects.all()
    c = {'events': events}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : texta-tk
@login_required
def get_table(request):
    polarity = request.GET['polarity']

    if request.GET['is_test'] == 'true':
        inclusive_test_grammar = json.loads(request.GET['inclusive_test_grammar'])
        #exclusive_test_grammar = json.loads(request.GET['exclusive_test_grammar'])

        layers = ['id'] + sorted(extract_layers(inclusive_test_grammar))
    else:
        inclusive_id = int(request.GET['inclusive_grammar_id'])
        exclusive_id = int(request.GET['exclusive_grammar_id'])

        inclusive_metaquery = generate_metaquery_dict(inclusive_id, request.user, component={})
        exclusive_metaquery = generate_metaquery_dict(exclusive_id, request.user, component={})
        layers = ['id'] + sorted(extract_layers(inclusive_metaquery) | extract_layers(exclusive_metaquery))

    template = loader.get_template('grammar_builder_table.html')
    return HttpResponse(template.render({'features':layers, 'polarity':polarity},request))

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def shosts(request):

    t = loader.get_template('shosts.html')
    shosts=SourceIp.objects.all()
    c = {'shosts': shosts}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def hosts(request):

    t = loader.get_template('hosts.html')
    hosts=Host.objects.all()
    c = {'hosts': hosts}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : utility_tags.py
Copyright MIT License
Author : PacktPublishing
    def render(self, context):
        try:
            # Loading the template and rendering it
            included_template = self.template_name.resolve(context)
            if isinstance(included_template, str):
                included_template = get_template(included_template)
            rendered_template = included_template.render(context)
        except (template.TemplateDoesNotExist,
                template.VariableDoesNotExist,
                AttributeError):
            rendered_template = ""
        return rendered_template

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def lm_sessions(request):

    t = loader.get_template('lm_sessions.html')
    progressions = PossibleLmSession.objects.all()
    deltas=[]
    for p in progressions:
        deltas.append(p.end-p.start)
    #print deltas
    c = {'progressions': progressions,'deltas':deltas}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : frontend_views.py
Copyright GNU General Public License v3.0
Author : CodigoSur
    def get_response(self, request, req_context, options, content_object):
        collection = content_object
        categories = Category.tree.filter(collection=collection, level=0)
        category_list = []
        for category in categories:
            category_list.extend(self.make_nested_list(category, True))
        req_context.update({'categories': category_list,
                            'collection_slug': collection.slug,
                            'align': options["align"]})
        t = loader.get_template(self.template)
        return t.render(req_context)

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def services(request):

    t = loader.get_template('services.html')
    services=Service.objects.all()

    c = {'services': services}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : texta-tk
@login_required
def index(request):
    template = loader.get_template('conceptualiser.html')

    lexicons = []
    for lexicon in Lexicon.objects.all().filter(author=request.user):
        setattr(lexicon,'size',Word.objects.all().filter(lexicon=lexicon.id).count())
        lexicons.append(lexicon)

    methods = ["PCA","TSNE","MDS"]

    datasets = Datasets().get_allowed_datasets(request.user)
    language_models =Task.objects.filter(task_type=TaskTypes.TRAIN_MODEL.value).filter(status__iexact=Task.STATUS_COMPLETED).order_by('-pk')
    
    return HttpResponse(template.render({'STATIC_URL':STATIC_URL,'lexicons':lexicons,'methods':methods, 'language_models': language_models, 'allowed_datasets': datasets},request))

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def suspicious_behavior_user(request,user_id):

    t = loader.get_template('suspicious_user_behavior_user.html')
    suspicious_behavior=SuspiciousUserBehavior.objects.filter(user_id=user_id)
    c = {'suspicious_behavior': suspicious_behavior}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def suspicious_behavior_source(request,source_id):

    t = loader.get_template('suspicious_source_behavior_source.html')
    suspicious_behavior=SuspiciousSourceBehavior.objects.filter(source_id=source_id)
    c = {'suspicious_behavior': suspicious_behavior}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : texta-tk
@login_required
@user_pastes_test(lambda u: u.is_superuser)
def list_script_projects(request):
    script_projects = ScriptProject.objects.all()

    template = loader.get_template('script_manager/project_list.html')
    return HttpResponse(template.render({'projects': script_projects}, request))

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def user(request, user_id):

    t = loader.get_template('user.html')
    user = User.objects.get(id=user_id)
    auth_remote = Event_4624.objects.filter(user=user).filter(Q(logontype="Network") | Q(logontype="RemoteInteractive")).order_by('time')
    auth_local = Event_4624.objects.filter(user=user).exclude(Q(logontype="Network") | Q(logontype="RemoteInteractive")).order_by('time')
    auth_failed = Event_4625.objects.filter(user=user).order_by('time')
    auth_local_user = Event_4776.objects.filter(user=user).order_by('time')
    hosts_remote=[]
    hosts_local = []
    for ar in Event_4624.objects.filter(user=user).filter(Q(logontype="Network") | Q(logontype="RemoteInteractive")).values('host').distinct():
        host=Host.objects.get(id=ar['host'])
        hosts_remote.append(host)

    for al in Event_4624.objects.filter(user=user).exclude(Q(logontype="Network") | Q(logontype="RemoteInteractive")).values('host').distinct():
        host=Host.objects.get(id=al['host'])
        hosts_local.append(host)
    c = {'user': user, 'auth_remote':auth_remote,'auth_local':auth_local,'auth_events':'auth_events','hosts_remote':hosts_remote,'hosts_local':hosts_local,'auth_failed':auth_failed,'auth_local_user':auth_local_user}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : utility_tags.py
Copyright MIT License
Author : PacktPublishing
    def render(self, context):
        try:
            # Loading the template and rendering it
            included_template = self.template_name.resolve(context)
            if isinstance(included_template, str):
                included_template = get_template(included_template)
            rendered_template = included_template.render(context)
        except (template.TemplateDoesNotExist,
                template.VariableDoesNotExist,
                AttributeError):
            rendered_template = ""
        return rendered_template

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def fa_cmdline_detail(request,cmdline_id):

    t = loader.get_template('fa_cmdline_detail.html')
    cmdline=FA_imagepath.objects.get(id=cmdline_id).imagepath

    services=Event_7045.objects.filter(service__imagepath=cmdline)
    tasks=Event_4698.objects.filter(task__imagepath=cmdline)
    c = {'services': services,'tasks':tasks}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : utility_tags.py
Copyright MIT License
Author : PacktPublishing
    def render(self, context):
        try:
            # Loading the template and rendering it
            included_template = self.template_name.resolve(context)
            if isinstance(included_template, str):
                included_template = get_template(included_template)
            rendered_template = included_template.render(context)
        except (template.TemplateDoesNotExist,
                template.VariableDoesNotExist,
                AttributeError):
            rendered_template = ""
        return rendered_template

3 View Complete Implementation : views_task_information.py
Copyright MIT License
Author : robotichead
@login_required(login_url='login',redirect_field_name="")
def information_task_delete_astigned_users(request, task_id, user_id):
    astigned_users_save = astigned_user.objects.filter(
        task_id=task_id,
        user_id=user_id,
    )
    astigned_users_save.update(is_deleted="TRUE")

    #Load template
    t = loader.get_template('NearBeach/blank.html')

    # context
    c = {}

    return HttpResponse(t.render(c, request))

3 View Complete Implementation : backends.py
Copyright Apache License 2.0
Author : BeanWei
    def to_html(self, request, queryset, view):
        filter_clast = self.get_filter_clast(view, queryset)
        if not filter_clast:
            return None
        filter_instance = filter_clast(request.query_params, queryset=queryset, request=request)

        template = loader.get_template(self.template)
        context = {
            'filter': filter_instance
        }

        return template.render(context, request)

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def fa_cmdline(request):

    t = loader.get_template('fa_cmdline.html')
    cmdlines=FA_imagepath.objects.all()

    c = {'cmdlines': cmdlines}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def tasks(request):

    t = loader.get_template('tasks.html')
    tasks=Task.objects.all()
    c = {'tasks': tasks}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views_quotes.py
Copyright MIT License
Author : robotichead
@login_required(login_url='login',redirect_field_name="")
def delete_line_item(request, line_item_id):
    # Delete the line item
    line_item = quote_product_and_service.objects.get(quotes_product_and_service_id = line_item_id)
    line_item.is_deleted = "TRUE"
    line_item.change_user=request.user
    line_item.save()

    #Return a blank page for fun
    t = loader.get_template('NearBeach/blank.html')

    # context
    c = {}

    return HttpResponse(t.render(c, request))

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def users(request):

    t = loader.get_template('users.html')
    users=User.objects.all().order_by('unique_succ_remote_hosts').reverse()
    c = {'users': users}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def service(request, service_id):

    t = loader.get_template('service.html')
    service= Service.objects.get(id=service_id)
    events= Event_7045.objects.filter(service=service)

    c = {'service': service,'events':events}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : texta-tk
@login_required
def index(request):
    template = loader.get_template('ontology_viewer.html')
    overview_data = [('Base lexicons created',str(len(Lexicon.objects.filter(author=request.user)))),
                     ('Concepts commited',str(len(Concept.objects.filter(author=request.user))))]

    datasets = Datasets().get_allowed_datasets(request.user)
    language_models =Task.objects.filter(task_type=TaskTypes.TRAIN_MODEL.value).filter(status__iexact='completed').order_by('-pk')

    return HttpResponse(template.render({'STATIC_URL':STATIC_URL,'overview_data':overview_data,'language_models': language_models, 
                                         'allowed_datasets': datasets},request))

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : texta-tk
@login_required
def table_header_mlt(request):
    ds = Datasets().activate_datasets(request.session)
    es_m = ds.build_manager(ES_Manager)

    # get columns names from ES mapping
    fields = es_m.get_column_names(facts=True)
    template_params = {'STATIC_URL': STATIC_URL,
                       'URL_PREFIX': URL_PREFIX,
                       'fields': fields,
                       'searches': Search.objects.filter(author=request.user),
                       'columns': [{'index': index, 'name': field_name} for index, field_name in enumerate(fields)],
                       }
    template = loader.get_template('mlt_results.html')
    return HttpResponse(template.render(template_params, request))

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def suspicious_behavior_type(request,type):
    #print type
    t = loader.get_template('suspicious_behavior_type.html')
    suspicious_user_behavior=SuspiciousUserBehavior.objects.filter(name=type)
    suspicious_host_behavior = SuspiciousSourceBehavior.objects.filter(name=type)
    #print len(suspicious_host_behavior)
    #print len(suspicious_user_behavior)
    c = {'suspicious_user_behavior': suspicious_user_behavior,"suspicious_host_behavior":suspicious_host_behavior}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : texta-tk
@login_required
def get_table_header(request):
    ds = Datasets().activate_datasets(request.session)
    es_m = ds.build_manager(ES_Manager)

    # get columns names from ES mapping
    fields = es_m.get_column_names(facts=True)
    template_params = {'STATIC_URL': STATIC_URL,
                       'URL_PREFIX': URL_PREFIX,
                       'fields': fields,
                       'searches': Search.objects.filter(author=request.user),
                       'columns': [{'index': index, 'name': field_name} for index, field_name in enumerate(fields)],
                       }
    template = loader.get_template('searcher_results.html')
    return HttpResponse(template.render(template_params, request))

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def suspicious_user_behavior_detail(request,s_id):

    t = loader.get_template('suspicious_user_behavior_detail.html')
    suspicious_behavior=SuspiciousUserBehavior.objects.get(id=s_id)

    auth_succ_remote=Event_4624.objects.filter(user=suspicious_behavior.user).filter(Q(logontype="Network") | Q(logontype="RemoteInteractive")).filter(time__range=(suspicious_behavior.start, suspicious_behavior.end)).order_by('time')
    auth_failed_remote = Event_4625.objects.filter(user=suspicious_behavior.user).filter(Q(logontype="Network") | Q(logontype="RemoteInteractive")).filter(time__range=(suspicious_behavior.start, suspicious_behavior.end)).order_by('time')

    unique_hosts_succ_remote=Event_4624.objects.filter(user=suspicious_behavior.user).filter(Q(logontype="Network") | Q(logontype="RemoteInteractive")).filter(time__range=(suspicious_behavior.start, suspicious_behavior.end)).values('host').distinct()
    unique_hosts_failed_remote = Event_4625.objects.filter(user=suspicious_behavior.user).filter(Q(logontype="Network") | Q(logontype="RemoteInteractive")).filter(time__range=(suspicious_behavior.start, suspicious_behavior.end)).values('host').distinct()

    local_auths=Event_4624.objects.filter(user=suspicious_behavior.user).exclude(Q(logontype="Network") | Q(logontype="RemoteInteractive")).filter(time__range=(suspicious_behavior.start, suspicious_behavior.end)).order_by('time')
    local_user_auths=Event_4776.objects.filter(user=suspicious_behavior.user).filter(time__range=(suspicious_behavior.start, suspicious_behavior.end))

    unique_hosts=len(unique_hosts_failed_remote)+len(unique_hosts_succ_remote)

    c = {'suspicious_behavior': suspicious_behavior,'auth_failed_remote':auth_failed_remote,'auth_succ_remote':auth_succ_remote,'local_auths':local_auths,'local_user_auths':local_user_auths,'unique_hosts':unique_hosts}

    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : texta-tk
@login_required
@user_pastes_test(lambda u: u.is_superuser)
def index(request):
    indices = ES_Manager.get_indices()
    indices = sorted(indices, key=lambda x: x['index'])  # sort alphabetically
    datasets = get_datasets(indices=indices)

    users = User.objects.all()
    users = annotate_users_with_permissions(users, datasets)
    template = loader.get_template('permission_admin.html')
    allowed_datasets = Datasets().get_allowed_datasets(request.user)

    language_models =Task.objects.filter(task_type=TaskTypes.TRAIN_MODEL.value).filter(status__iexact=Task.STATUS_COMPLETED).order_by('-pk')

    return HttpResponse(template.render({'users':users,'datasets':datasets,'indices':indices,'STATIC_URL':STATIC_URL,'URL_PREFIX':URL_PREFIX, 'allowed_datasets': allowed_datasets, 'language_models': language_models},request))

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def lmsession(request, lmsession_id):

    t = loader.get_template('lmsession.html')
    aprogression=PossibleLmSession.objects.get(id=lmsession_id)
    #print type(aprogression.attacks.all())
    events= aprogression.attacks.all().order_by('auth__time')
    c= {'aprogression': aprogression,'events': events}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : texta-tk
@login_required
def index(request):
    datasets = Datasets().get_allowed_datasets(request.user)
    language_models =Task.objects.filter(task_type=TaskTypes.TRAIN_MODEL.value).filter(status__iexact=Task.STATUS_COMPLETED).order_by('-pk')

    template = loader.get_template('lm.html')
    lexicons = Lexicon.objects.all().filter(author=request.user)
    return HttpResponse(template.render({'lexicons': lexicons, 'STATIC_URL': STATIC_URL, 'language_models': language_models, 'allowed_datasets': datasets}, request))

3 View Complete Implementation : views_administration.py
Copyright MIT License
Author : robotichead
@login_required(login_url='login',redirect_field_name="")
def list_of_taxes_list(request):
    permission_results = return_user_permission_level(request, None, 'tax')

    if permission_results['tax'] == 0:
        return HttpResponseRedirect(reverse('permission_denied'))

    list_of_taxes_results = list_of_tax.objects.all().order_by('tax_amount') #No taxes are deleted, only disabled.

    #Load template
    t = loader.get_template('NearBeach/list_of_taxes/list_of_taxes_list.html')

    # context
    c = {
        'list_of_taxes_results': list_of_taxes_results,
    }

    return HttpResponse(t.render(c, request))

3 View Complete Implementation : filters.py
Copyright Apache License 2.0
Author : BeanWei
    def to_html(self, request, queryset, view):
        if not getattr(view, 'search_fields', None):
            return ''

        term = self.get_search_terms(request)
        term = term[0] if term else ''
        context = {
            'param': self.search_param,
            'term': term
        }
        template = loader.get_template(self.template)
        return template.render(context)

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def suspicious_user_behavior(request):

    t = loader.get_template('suspicious_user_behavior.html')
    users=User.objects.annotate(suspicious_count=Count('suspicioususerbehavior')).filter(suspicious_count__gt=0)

    c = {'users': users}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : utility_tags.py
Copyright MIT License
Author : PacktPublishing
    def render(self, context):
        try:
            # Loading the template and rendering it
            included_template = self.template_name.resolve(context)
            if isinstance(included_template, str):
                included_template = get_template(included_template)
            rendered_template = included_template.render(context)
        except (template.TemplateDoesNotExist,
                template.VariableDoesNotExist,
                AttributeError):
            rendered_template = ""
        return rendered_template

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def suspicious_source_behavior_detail(request,s_id):

    t = loader.get_template('suspicious_source_behavior_detail.html')
    suspicious_behavior=SuspiciousSourceBehavior.objects.get(id=s_id)

    auth_succ_remote=Event_4624.objects.filter(sourceip=suspicious_behavior.source).filter(Q(logontype="Network") | Q(logontype="RemoteInteractive")).filter(time__range=(suspicious_behavior.start, suspicious_behavior.end)).order_by('time')
    auth_failed_remote = Event_4625.objects.filter(sourceip=suspicious_behavior.source).filter(Q(logontype="Network") | Q(logontype="RemoteInteractive")).filter(time__range=(suspicious_behavior.start, suspicious_behavior.end)).order_by('time')

    hosts_succ_remote=Event_4624.objects.filter(sourceip=suspicious_behavior.source).filter(Q(logontype="Network") | Q(logontype="RemoteInteractive")).filter(time__range=(suspicious_behavior.start, suspicious_behavior.end)).values('host').distinct()
    hosts_failed_remote = Event_4625.objects.filter(sourceip=suspicious_behavior.source).filter(Q(logontype="Network") | Q(logontype="RemoteInteractive")).filter(time__range=(suspicious_behavior.start, suspicious_behavior.end)).values('host').distinct()

    unique_hosts=len(hosts_failed_remote)+len(hosts_succ_remote)

    c = {'suspicious_behavior': suspicious_behavior,'auth_failed_remote':auth_failed_remote,'auth_succ_remote':auth_succ_remote,'unique_hosts':unique_hosts}

    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : utility_tags.py
Copyright MIT License
Author : PacktPublishing
    def render(self, context):
        try:
            # Loading the template and rendering it
            included_template = self.template_name.resolve(context)
            if isinstance(included_template, str):
                included_template = get_template(included_template)
            rendered_template = included_template.render(context)
        except (template.TemplateDoesNotExist,
                template.VariableDoesNotExist,
                AttributeError):
            rendered_template = ""
        return rendered_template

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def possible_lm_detail(request, possiblelm_id):

    t = loader.get_template('possible_lm_detail.html')
    event=PossibleLM.objects.get(id=possiblelm_id)
    c = {'event': event, 'hosts': hosts}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : utility_tags.py
Copyright MIT License
Author : PacktPublishing
    def render(self, context):
        try:
            # Loading the template and rendering it
            included_template = self.template_name.resolve(context)
            if isinstance(included_template, str):
                included_template = get_template(included_template)
            rendered_template = included_template.render(context)
        except (template.TemplateDoesNotExist,
                template.VariableDoesNotExist,
                AttributeError):
            rendered_template = ""
        return rendered_template

3 View Complete Implementation : views_administration.py
Copyright MIT License
Author : robotichead
@login_required(login_url='login',redirect_field_name="")
def list_of_taxes_deactivate(request,tax_id):
    if request.method == "POST":
        tax_instance = list_of_tax.objects.get(tax_id=tax_id)
        if tax_instance.is_deleted == "FALSE":
            tax_instance.is_deleted = "TRUE"
        else:
            tax_instance.is_deleted = "FALSE"
        tax_instance.save()

        #Return blank page
        t = loader.get_template('NearBeach/blank.html')

        c= {}

        return HttpResponse(t.render(c, request))
    else:
        return HttpResponseBadRequest("Sorry, can only be done through POST")

3 View Complete Implementation : renderers.py
Copyright Apache License 2.0
Author : BeanWei
    def render(self, data, accepted_media_type=None, renderer_context=None):
        """
        Render the HTML for the browsable API representation.
        """
        self.accepted_media_type = accepted_media_type or ''
        self.renderer_context = renderer_context or {}

        template = loader.get_template(self.template)
        context = self.get_context(data, accepted_media_type, renderer_context)
        ret = template.render(context, request=renderer_context['request'])

        # Munge DELETE Response code to allow us to return content
        # (Do this *after* we've rendered the template so that we include
        # the normal deletion response code in the output)
        response = renderer_context['response']
        if response.status_code == status.HTTP_204_NO_CONTENT:
            response.status_code = status.HTTP_200_OK

        return ret

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def suspicious_source_behavior(request):

    t = loader.get_template('suspicious_source_behavior.html')
    sources=SourceIp.objects.annotate(suspicious_count=Count('suspicioussourcebehavior')).filter(suspicious_count__gt=0)

    c = {'sources': sources}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def suspicious_behavior(request):

    t = loader.get_template('suspicious_behavior.html')
    types=["User: Privilege Enumeration","User: High number of destinations","User: Roaming Authentication","User: Local Account Usage","Source Host: Possible User Enumeration","Source Host: Possible Pastword Spray/Brute Force","Source Host: High number of users"]
    totals=[]
    for type in types:
        total=len(SuspiciousUserBehavior.objects.filter(name=type))
        if total >0:
            totals.append([type,total])

    for type in types:
        total=len(SuspiciousSourceBehavior.objects.filter(name=type))
        if total >0:
            totals.append([type,total])

    c = {'totals': totals}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views_document_tree.py
Copyright MIT License
Author : robotichead
@login_required(login_url='login',redirect_field_name="")
def delete_folder(request, folder_id):
    if request.method == "POST":
        folder_results = folder.objects.get(folder_id=folder_id)
        folder_results.is_deleted = "TRUE"
        folder_results.change_user = request.user
        folder_results.save()

        t = loader.get_template('NearBeach/blank.html')
        c = {}
        return HttpResponse(t.render(c,request))
    else:
        return HttpResponseBadRequest("Sorry, this request has to be post")

3 View Complete Implementation : views_administration.py
Copyright MIT License
Author : robotichead
@login_required(login_url='login',redirect_field_name="")
def list_of_taxes_information(request):
    permission_results = return_user_permission_level(request, None, 'tax')

    if permission_results['tax'] == 0:
        return HttpResponseRedirect(reverse('permission_denied'))

    #Load template
    t = loader.get_template('NearBeach/list_of_taxes/list_of_taxes_information.html')

    # context
    c = {
        'new_item_permission': permission_results['new_item'],
        'administration_permission': permission_results['administration'],
    }

    return HttpResponse(t.render(c, request))

3 View Complete Implementation : views_quotes.py
Copyright MIT License
Author : robotichead
@login_required(login_url='login',redirect_field_name="")
def delete_responsible_customer(request,quote_id,customer_id):
    if request.method == "POST":
        quote_responsible_customer.objects.filter(
            is_deleted="FALSE",
            quote_id=quote.objects.get(quote_id=quote_id),
            customer_id=customer.objects.get(customer_id=customer_id)
        ).update(is_deleted="TRUE")
        #Return a blank page for fun
        t = loader.get_template('NearBeach/blank.html')

        # context
        c = {}

        return HttpResponse(t.render(c, request))
        #SoMuchFun
    else:
        return HttpResponseBadRequest("Delete Responsible Customer has to be done in POST")

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : mvelazc0
def task(request, task_id):

    t = loader.get_template('task.html')
    task= Task.objects.get(id=task_id)
    events= Event_4698.objects.filter(task=task)
    c = {'task': task,'events':events}
    return HttpResponse(t.render(c, request), content_type='text/html')

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : texta-tk
@login_required
def results(request):
    template = loader.get_template('mwe_results.html')
    run_id  = request.GET['run_id']
    results = json.loads(Run.objects.get(pk=run_id).results)
    results = sorted([results[key] for key in results],key=lambda x: x[u'total_freq'],reverse=True)
    out = []
    for group in results:
        children_ids = []
        for mwe in group['mwes']:
            children_ids.append(mwe['id'])
        group['mwe_ids'] = children_ids
        out.append(group)
    return HttpResponse(template.render({'results':out,'run_id':run_id,'STATIC_URL':STATIC_URL},request))

1 2 3