当前位置: 首页>>代码示例>>Python>>正文


Python django_tables2.RequestConfig类代码示例

本文整理汇总了Python中django_tables2.RequestConfig的典型用法代码示例。如果您正苦于以下问题:Python RequestConfig类的具体用法?Python RequestConfig怎么用?Python RequestConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RequestConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: prefs

def prefs(req, user=None):
   '''
   Show the preference page of the specified user. 
   If requesting to show user that is not current session,
   the superuser permission are required.
   '''
   if user==None: user=req.user.username
   if user!=req.user.username and not req.user.is_superuser:
      if req.user.username!=user: return HttpResponseForbidden('<h1>403-Forbidden</h1>')
   user=getObj(get_user_model(), username=user)
   if req.method=='POST':
      newPwd=req.POST.get('newPwd', None)
      if newPwd and newPwd==req.POST.get('rePwd', None):
         user.set_password(newPwd)
         user.save()
         auth_logout(req)
         return redirect('webframe:prefs', user=user)

   params=dict()
   params['preference']=PreferenceTable(Preference.objects.filter(owner=req.user, parent__isnull=True))
   params['config']=PreferenceTable(Preference.objects.filter(owner__isnull=True, parent__isnull=True))
   rc=RequestConfig(req)
   rc.configure(params['preference'])
   rc.configure(params['config'])
   params['currentuser']=user
   if req.user.has_perm('webframe.add_config') or req.user.has_perm('webframe.change.config'):
      m=hashlib.md5()
      m.update(user.username.encode('utf-8'))
      m.update(CONFIG_KEY.encode('utf-8'))
      params['config_key']=m.hexdigest()
   return render(req, getattr(settings, 'TMPL_PREFERENCES', 'webframe/preferences.html'), params)
开发者ID:kensonman,项目名称:webframe,代码行数:31,代码来源:views.py

示例2: filters_list

def filters_list(request):
    public_view = PublicFiltersView(request, model=TestRunFilter, table_class=PublicFiltersTable)
    prefix = "public_"
    public_filters_table = PublicFiltersTable(public_view.get_table_data(prefix), prefix=prefix)
    config = RequestConfig(request)
    config.configure(public_filters_table)

    search_data = public_filters_table.prepare_search_data(public_view)
    discrete_data = public_filters_table.prepare_discrete_data(public_view)
    terms_data = public_filters_table.prepare_terms_data(public_view)
    times_data = public_filters_table.prepare_times_data(public_view)

    user_filters_table = None
    if request.user.is_authenticated():
        user_view = UserFiltersView(request, model=TestRunFilter, table_class=UserFiltersTable)
        prefix = "user_"
        user_filters_table = UserFiltersTable(user_view.get_table_data(prefix), prefix=prefix)
        config.configure(user_filters_table)
        search_data.update(user_filters_table.prepare_search_data(user_view))
        discrete_data.update(user_filters_table.prepare_discrete_data(user_view))
        terms_data.update(user_filters_table.prepare_terms_data(user_view))

    return render_to_response(
        "dashboard_app/filters_list.html",
        {
            "user_filters_table": user_filters_table,
            "public_filters_table": public_filters_table,
            "terms_data": terms_data,
            "search_data": search_data,
            "times_data": times_data,
            "discrete_data": discrete_data,
            "bread_crumb_trail": BreadCrumbTrail.leading_to(filters_list),
        },
        RequestContext(request),
    )
开发者ID:SivagnanamCiena,项目名称:lava-server-1,代码行数:35,代码来源:views.py

示例3: TableHelperMixin

class TableHelperMixin(object):

    """
    provide a function add_table that you can call in a get_context_data to add and configure tables from querysets
    """

    table_context_name_base = 'mtable'
    mtables = 0
    tconfig = None

    def get_new_table_context_name(self):
        return '{}{}'.format(self.table_context_name_base, self.mtables)

    def add_table(self, context, qs, table_class=None, with_report=False, context_name=None, **kwargs):
        """
        context = context from  get_context_data (dict)
        qs = the qs for the table
        table_class = Table class to use, auto generated from model if not provided.
            kwargs = will be used in the auto generation table class.
        with_report = FIXME: not showing export buttons right now.
        context_name = specify context name for the table
        """
        if not self.mtables:
            self.mtables = 0
        if not self.tconfig:
            self.config = RequestConfig(self.request)

        convert_to_list = kwargs.get('convert_to_list')
        if not table_class:
            if with_report:
                table_class = create_report_table(qs.model, **kwargs)
            else:
                table_class = create_model_table(qs.model, **kwargs)

        if convert_to_list:
            table_fields = kwargs.get('table_fields', [])
            if table_fields:
                qs_list = self.convert_qs_to_list(qs, table_fields)
            else:
                qs_list = qs.values()
            qs_list = list(qs_list)
            table = table_class(qs_list)
        else:
            table = table_class(qs)
        self.config.configure(table)
        self.mtables = self.mtables + 1
        context[context_name or self.get_new_table_context_name()] = table
        return table

    def convert_qs_to_list(self, qs, table_fields):
        qs_list = []
        for obj in qs:
            obj_dict = {}
            for f in table_fields:
                x = getattr(obj, f)
                if hasattr(x, '__call__'):
                    x = x()
                obj_dict[f] = x
            qs_list.append(obj_dict)
        return qs_list
开发者ID:jericksanjuan,项目名称:django-tables2-extras,代码行数:60,代码来源:mixins.py

示例4: ondemand

def ondemand(request):
    """provides on demand portion of site

    """
    now = datetime.today()
    channels_filtered=request.GET.getlist('channels')

    type_filtered=request.GET.get('type')

    #switch the value of type filtered to the other so that it can properly exclude the opposite value
    if type_filtered=="Tv":
        type_filtered="Movie"
    elif type_filtered=="Movie":
        type_filtered="Tv"

    if channels_filtered:
        #filters out any channel that was passed in the Get request as checkmarked
        #channels_removed_obj_list = [obj for obj in Titles.objects.all() if any(name in obj.channel for name in channels_filtered)]

        ob_list_channelsremoved = Ondemand_Titles.objects.exclude(reduce(lambda x, y: x | y, [Q(channel__contains=word) for word in channels_filtered]))
    else:
        ob_list_channelsremoved=Ondemand_Titles.objects.all()


    config = RequestConfig(request,paginate={"per_page":40   })
    table1= OndemandTable(ob_list_channelsremoved)
    config.configure(table1)
    return render(request, 'ondemand.html', {'table1':table1,'current_date':now,})
开发者ID:josh3336,项目名称:imdb_guide,代码行数:28,代码来源:views.py

示例5: get

 def get(self, request, *args, **kwargs):
     context = self.get_context_data(**kwargs)
     config = RequestConfig(request)
     table = self.table_class(self.object_list)
     config.configure(table)
     table.paginate(page=request.GET.get('page', 1), per_page=self.table_pagination)
     context[self.context_table_name] = table
     return self.render_to_response(context)
开发者ID:leotop,项目名称:koalixcrm,代码行数:8,代码来源:views.py

示例6: coordinate

def coordinate(request):
    all = Interval.objects.all()
    coordinates= CoordinateTable(all)
    avg_counts = CoordinateTable(Read_alignment.objects.annotate(Avg('read_counts'))) 
    config = RequestConfig(request)
    config.configure(coordinates)
    config.configure(avg_counts)
    return render(request,"srb/coordinate.html",{'coordinates':coordinates,'avg_counts':avg_counts })
开发者ID:alvinwt,项目名称:DjangoSRBdB,代码行数:8,代码来源:views.py

示例7: get_queryset

    def get_queryset(self):
        queryset = super(SelectRelatedMixin, self).get_queryset()
        config = RequestConfig(self.request)
        user = User.objects.get(pk=self.request.user.id)

        customer = HistoryTable(queryset.select_related(*self.select_related).filter(customer=user.customer))
        config.configure(customer)
        return customer
开发者ID:7WebPages,项目名称:dj-stripe,代码行数:8,代码来源:views.py

示例8: query_custom

def query_custom(request):

    try:
        content_type = Query.get_content_type(request.GET.get("entity"))
    except InvalidContentTypeError as e:
        messages.error(request, e)
        raise Http404()

    if content_type.model_class() not in QueryCondition.RELATION_MAP:
        messages.error(
            request,
            "Wrong table name in entity param. Please refer to query docs.")
        raise Http404()

    try:
        conditions = Query.parse_conditions(content_type,
                                            request.GET.get("conditions"))
    except InvalidConditionsError as e:
        messages.error(request, e)
        raise Http404()

    view = QueryCustomResultView(
        content_type=content_type,
        conditions=conditions,
        request=request,
        model=content_type.model_class(),
        table_class=QUERY_CONTENT_TYPE_TABLE[content_type.model_class()]
    )

    try:
        table = QUERY_CONTENT_TYPE_TABLE[content_type.model_class()](
            None,
            request.user,
            view.get_table_data()
        )
    except (FieldDoesNotExist, FieldError) as e:
        messages.error(request, e)
        raise Http404()

    config = RequestConfig(request, paginate={"per_page": table.length})
    config.configure(table)
    template = loader.get_template('lava_results_app/query_custom.html')
    return HttpResponse(template.render(
        {
            'query_table': table,
            'conditions': conditions,
            'terms_data': table.prepare_terms_data(view),
            'search_data': table.prepare_search_data(view),
            'discrete_data': table.prepare_discrete_data(view),

            'bread_crumb_trail': BreadCrumbTrail.leading_to(query_custom),
            'context_help': ['lava-queries-charts'],
        }, request=request)
    )
开发者ID:Linaro,项目名称:lava-server,代码行数:54,代码来源:views.py

示例9: equipments

def equipments(request):
	q = request.GET.get('q')
	if ( q is None ) :
		table = EquipmentTable(Equipment.objects.all())
		q=''
	else:
		table = EquipmentTable(Equipment.objects.filter(Q(serial_number__exact=q) | Q(location_business_name__contains=q)))
	config = RequestConfig(request, paginate={"per_page": 10})
	config.configure(table)

	return render(request, "ems/equipment_table.html", {"table": table, 'search_var':q})
开发者ID:sonnyw,项目名称:sparrowems,代码行数:11,代码来源:views.py

示例10: inventoryOrderReportsView

def inventoryOrderReportsView(request, pk=None):
	permissions = get_object_or_404(UserPermissions, user=request.user)
	order = get_object_or_404(InventoryOrder, pk=pk)
	order_reports = InventoryRoomReportTable(InventoryRoomReport.objects.filter(order=order), prefix='rr-')
	done_rooms = InventoryRoomReport.objects.filter(order=order).values_list('room__id', flat=True)
	remaining_rooms = RoomTableNoEdit(Room.objects.exclude(id__in=done_rooms), prefix='r-')
	config = RequestConfig(request)
	config.configure(order_reports)
	config.configure(remaining_rooms)
	
	return render(request, 'inventoryOrderReports.html', { 'permissions' : permissions , 'order_reports' : order_reports , 'remaining_rooms' : remaining_rooms , 'order' : order , 'finish' : Room.objects.exclude(id__in=done_rooms).exists() })
开发者ID:Valumior,项目名称:inventory,代码行数:11,代码来源:views.py

示例11: chart_list

def chart_list(request):

    group_tables = {}
    terms_data = search_data = discrete_data = {}
    for group in ChartGroup.objects.all():
        if group.chart_set.count():
            prefix = "group_%s_" % group.id
            group_view = GroupChartView(request, group, model=Chart,
                                        table_class=GroupChartTable)
            table = GroupChartTable(group_view.get_table_data(prefix),
                                    prefix=prefix)
            search_data.update(table.prepare_search_data(group_view))
            discrete_data.update(table.prepare_discrete_data(group_view))
            terms_data.update(table.prepare_terms_data(group_view))
            group_tables[group.name] = table
            config = RequestConfig(request,
                                   paginate={"per_page": table.length})
            config.configure(table)

    prefix = "other_"
    other_view = OtherChartView(request, model=Chart,
                                table_class=OtherChartTable)
    other_chart_table = OtherChartTable(other_view.get_table_data(prefix),
                                        prefix=prefix)
    config = RequestConfig(request,
                           paginate={"per_page": other_chart_table.length})
    config.configure(other_chart_table)
    search_data.update(other_chart_table.prepare_search_data(other_view))
    discrete_data.update(other_chart_table.prepare_discrete_data(other_view))
    terms_data.update(other_chart_table.prepare_terms_data(other_view))

    if request.user.is_authenticated():
        prefix = "user_"
        view = UserChartView(request, model=Chart, table_class=UserChartTable)
        user_chart_table = UserChartTable(view.get_table_data(prefix),
                                          prefix=prefix)
        config = RequestConfig(request,
                               paginate={"per_page": user_chart_table.length})
        config.configure(user_chart_table)
        search_data.update(user_chart_table.prepare_search_data(view))
        discrete_data.update(user_chart_table.prepare_discrete_data(view))
        terms_data.update(user_chart_table.prepare_terms_data(view))
    else:
        user_chart_table = None
    template = loader.get_template('lava_results_app/chart_list.html')
    return HttpResponse(template.render(
        {
            'user_chart_table': user_chart_table,
            'other_chart_table': other_chart_table,
            'search_data': search_data,
            "discrete_data": discrete_data,
            'terms_data': terms_data,
            'group_tables': group_tables,
            'bread_crumb_trail': BreadCrumbTrail.leading_to(chart_list),
            'context_help': ['lava-queries-charts'],
        }, request=request)
    )
开发者ID:Linaro,项目名称:lava-server,代码行数:57,代码来源:views.py

示例12: query_list

def query_list(request):

    group_tables = {}
    terms_data = search_data = discrete_data = {}
    for group in QueryGroup.objects.all():
        if group.query_set.count():
            prefix = "group_%s_" % group.id
            group_view = GroupQueryView(request, group, model=Query,
                                        table_class=GroupQueryTable)
            table = GroupQueryTable(group_view.get_table_data(prefix),
                                    prefix=prefix)
            search_data.update(table.prepare_search_data(group_view))
            discrete_data.update(table.prepare_discrete_data(group_view))
            terms_data.update(table.prepare_terms_data(group_view))
            group_tables[group.name] = table
            config = RequestConfig(request,
                                   paginate={"per_page": table.length})
            config.configure(table)

    prefix = "other_"
    other_view = OtherQueryView(request, model=Query,
                                table_class=OtherQueryTable)
    other_query_table = OtherQueryTable(other_view.get_table_data(prefix),
                                        prefix=prefix)
    config = RequestConfig(request,
                           paginate={"per_page": other_query_table.length})
    config.configure(other_query_table)
    search_data.update(other_query_table.prepare_search_data(other_view))
    discrete_data.update(other_query_table.prepare_discrete_data(other_view))
    terms_data.update(other_query_table.prepare_terms_data(other_view))

    if request.user.is_authenticated():
        prefix = "user_"
        view = UserQueryView(request, model=Query, table_class=UserQueryTable)
        user_query_table = UserQueryTable(view.get_table_data(prefix),
                                          prefix=prefix)
        config = RequestConfig(request,
                               paginate={"per_page": user_query_table.length})
        config.configure(user_query_table)
        search_data.update(user_query_table.prepare_search_data(view))
        discrete_data.update(user_query_table.prepare_discrete_data(view))
        terms_data.update(user_query_table.prepare_terms_data(view))
    else:
        user_query_table = None

    return render_to_response(
        'lava_results_app/query_list.html', {
            'user_query_table': user_query_table,
            'other_query_table': other_query_table,
            'search_data': search_data,
            "discrete_data": discrete_data,
            'terms_data': terms_data,
            'group_tables': group_tables,
            'bread_crumb_trail': BreadCrumbTrail.leading_to(query_list),
            'context_help': BreadCrumbTrail.leading_to(query_list),
        }, RequestContext(request)
    )
开发者ID:jguyot,项目名称:lava-server,代码行数:57,代码来源:views.py

示例13: addressDetailView

def addressDetailView(request, pk=None):
	if pk:
		address = get_object_or_404(Address, id=pk)
		permissions = get_object_or_404(UserPermissions, user=request.user)
		if permissions.is_admin:
			rooms = RoomTable(Room.objects.filter(address=address), prefix='r-')
		else:
			rooms = RoomTableNoEdit(Room.objects.filter(address=address), prefix='r-')
		entries = EntryTable(Entry.objects.filter(room__address=address), prefix='e-')
		config = RequestConfig(request)
		config.configure(rooms)
		config.configure(entries)
		return render(request, 'addressDetails.html', { 'address' : address , 'rooms' : rooms , 'entries' : entries })
	return HttpResponseRedirect(reverse('address'))
开发者ID:Valumior,项目名称:inventory,代码行数:14,代码来源:views.py

示例14: result

def result(request, task_id=None):
    # read from celery the results
    # save CSV file
    task_results = celery_app.AsyncResult(task_id).get()
    scoring_df = pd.read_csv(StringIO(task_results))
    scoring_df = scoring_df.fillna('')
    scoring_results_table = ScoringTable(scoring_df.to_dict('records'))
    config = RequestConfig(request)
    config.paginate = False
    config.configure(scoring_results_table)
    return render_to_response('review_scoring/result.html',
                              {"scoring_results": scoring_results_table,
                               "task_id": task_id,
                               "scoring_plot": create_html_plot_tooltip(scoring_df)},
                              context_instance=RequestContext(request))
开发者ID:mdw771,项目名称:reviewer_assignment,代码行数:15,代码来源:views.py

示例15: add_table

    def add_table(self, context, qs, table_class=None, with_report=False, context_name=None, **kwargs):
        """
        context = context from  get_context_data (dict)
        qs = the qs for the table
        table_class = Table class to use, auto generated from model if not provided.
            kwargs = will be used in the auto generation table class.
        with_report = FIXME: not showing export buttons right now.
        context_name = specify context name for the table
        """
        if not self.mtables:
            self.mtables = 0
        if not self.tconfig:
            self.config = RequestConfig(self.request)

        convert_to_list = kwargs.get('convert_to_list')
        if not table_class:
            if with_report:
                table_class = create_report_table(qs.model, **kwargs)
            else:
                table_class = create_model_table(qs.model, **kwargs)

        if convert_to_list:
            table_fields = kwargs.get('table_fields', [])
            if table_fields:
                qs_list = self.convert_qs_to_list(qs, table_fields)
            else:
                qs_list = qs.values()
            qs_list = list(qs_list)
            table = table_class(qs_list)
        else:
            table = table_class(qs)
        self.config.configure(table)
        self.mtables = self.mtables + 1
        context[context_name or self.get_new_table_context_name()] = table
        return table
开发者ID:jericksanjuan,项目名称:django-tables2-extras,代码行数:35,代码来源:mixins.py


注:本文中的django_tables2.RequestConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。