Exemple #1
0
    def test_get_context_data(self):
        self.mock.StubOutWithMock(ListView, "get_context_data")
        self.mock.StubOutWithMock(self.view, "get_category")

        ListView.get_context_data().AndReturn({})
        self.view.get_category().AndReturn("a category")

        self.mock.ReplayAll()
        context = self.view.get_context_data()
        self.mock.VerifyAll()

        self.assertEqual(context["category"], "a category")
Exemple #2
0
    def test_get_context_data(self):
        self.mock.StubOutWithMock(ListView, 'get_context_data')
        self.mock.StubOutWithMock(self.view, 'get_category')

        ListView.get_context_data().AndReturn({})
        self.view.get_category().AndReturn('a category')

        self.mock.ReplayAll()
        context = self.view.get_context_data()
        self.mock.VerifyAll()

        self.assertEqual(context['category'], 'a category')
Exemple #3
0
    def test_get_context_data(self):
        self.mock.StubOutWithMock(ListView, 'get_context_data')
        self.mock.StubOutWithMock(self.view, 'get_category')

        ListView.get_context_data().AndReturn({})
        self.view.get_category().AndReturn('a category')

        self.mock.ReplayAll()
        context = self.view.get_context_data()
        self.mock.VerifyAll()

        self.assertEqual(context['category'], 'a category')
Exemple #4
0
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     context['object_list'] = context['object_list'][::-1] #reverse these at the last minute
     context['room'] = get_object_or_404(Room, name=self.kwargs.get('room'))
     context['form'] = ChatForm()
     context['poll_delay'] = getattr(settings, 'CHAT_REFRESH_RATE', 2)
     return context
Exemple #5
0
 def get_context_data(self, *args, **kwargs):
     data = ListView.get_context_data(self, *args, **kwargs)
     form = MatchSearchForm()
     if self.request.GET:
         form = MatchSearchForm(data=self.request.GET)
     data.update({"search_form": form})
     return data
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)

        if self.kwargs.get('idsolicitud', None):
            context['idsolicitud'] = int(self.kwargs['idsolicitud'])

        if self.kwargs.get('idfase', None):
            context['idfase'] = self.kwargs['idfase']
        #solicitudes_proyecto
        if self.kwargs.get('idproyecto', None):
            context['idproyecto'] = self.kwargs['idproyecto']
        
        EST_SOLICITUD = {'E_APROBADO': SolicitudCambio.E_APROBADO, \
                         'E_RECHAZADO': SolicitudCambio.E_RECHAZADO,\
                         'E_ENVIADO': SolicitudCambio.E_ENVIADO, \
                         'E_TERMINADO': SolicitudCambio.E_TERMINADO,\
                         'E_BORRADOR': SolicitudCambio.E_BORRADOR }
        #variable que indica si el usuario es miembro del comite
        if self.usuario_essolic:
            context['usuario_essolic'] = self.usuario_essolic
            
        context['EST_SOLICITUD'] = EST_SOLICITUD
        context['titulo'] = self.titulo 
        context['explicacion'] = self.explicacion 

        return  context
Exemple #7
0
 def get_context_data(self, **kwargs):
     form_class = self.get_form_class()
     form = self.get_form(form_class)
     data = ListView.get_context_data(self, object_list=self.object_list)
     data['form'] = form
     data['EMAIL_TAGS'] = EMAIL_TAGS
     return data 
Exemple #8
0
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     EST_PROYECTO = {'E_FINALIZADO': Proyecto.E_FINALIZADO, \
                     'E_INICIADO': Proyecto.E_INICIADO , \
                     'E_NOINICIADO' : Proyecto.E_NOINICIADO }
     context['EST_PROYECTO'] = EST_PROYECTO
     return context
Exemple #9
0
    def get_context_data(self, **kwargs):
        context = {}

        context.update(FormView.get_context_data(self, **kwargs))
        context.update(ListView.get_context_data(self, **kwargs))

        return context
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     context['idfase'] = self.kwargs['idfase']
     if self.kwargs.get('idlineabase', None):
         context['idlineabase'] = int(self.kwargs['idlineabase'])
     context['itemslb'] = self.lista_items
     return context
Exemple #11
0
 def get_context_data(self, *args, **kwargs):
     context = ListView.get_context_data(self, *args, **kwargs)
     context.update(BaseView.get_context_data(self, *args, **kwargs))
     activities = Content.objects.filter(slug="atividades")
     if activities.exists():
         context["content"] = activities[0]
     return context
Exemple #12
0
	def get_context_data(self, **kwargs):
		kwargs = ListView.get_context_data(self, **kwargs)
		kwargs['query'] = self.query
		if self.newspaper_id:
			kwargs['newspaper'] = Article.objects.values('newspaper_title', 'newspaper_id').filter(newspaper_id=self.newspaper_id)[0]
		kwargs['order'] = self.current_order
		return kwargs
Exemple #13
0
	def get_context_data(self, **kwargs):
		kwargs = ListView.get_context_data(self, **kwargs)
		kwargs['query'] = self.query
		if self.domain:
			kwargs['domain'] = self.domain
		kwargs['order'] = self.current_order
		return kwargs
Exemple #14
0
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     context["images"] = BoatImage.objects.all().distinct('boat')  # выбирает только 1
     # уникальный объект из группы объектов с  одинаковым фк, остальные отсеивает
     if self.field and self.mark:
         context["verbose_name"] = self.verbose_name
     return context
Exemple #15
0
 def get_context_data(self, **kwargs):
     # Is this a bit of a hack? Use better inheritance?
     kwargs_article = ArticleMixin.get_context_data(self, **kwargs)
     kwargs_listview = ListView.get_context_data(self, **kwargs)
     kwargs.update(kwargs_article)
     kwargs.update(kwargs_listview)
     kwargs['selected_tab'] = 'history'
     return kwargs
 def get_context_data(self, **kwargs):
     idsolicitud = self.kwargs['idsolicitud']
     context = ListView.get_context_data(self, **kwargs)
     estado = VotaSolicitudView.estado_votacion(idsolicitud)
     context['favor'] = estado[0]
     context['contra'] = estado[1]
     context['faltantes'] = estado[2]
     return context
Exemple #17
0
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)

        # Set '?next=' if needed
        if 'filter' in self.kwargs and self.kwargs['filter'] == 'archived':
            context['archived'] = True
            context['next'] = '?next=archived'

        return context
Exemple #18
0
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     context['user_list'] = self.box.thread.recipients
     context['date_read'] = copy.copy(self.box.date_read)
     context['box'] = self.box
     context['form'] = ReplyForm()
     
     self.box.mark_read()
     return context
Exemple #19
0
    def get_context_data(self, **kwargs):
        np = get_newspaper(self.newspaper_id())
        year = get_year(self.year_id())

        context = ListView.get_context_data(self, **kwargs)
        context.update({
            "np": np,
            "year": year,
        })
        return context
    def get_context_data(self, **kwargs):
        """
        Add a list of filters and self.form to the context to be rendered by
        the view.
        """
        kwargs = ListView.get_context_data(self, **kwargs)
        kwargs['form'] = self.form
        kwargs['filters'] = self.get_filters()

        return kwargs
Exemple #21
0
    def get_context_data(self, *args, **kwargs):
        context = ListView.get_context_data(self, *args, **kwargs)
        context.update(BaseView.get_context_data(self, *args, **kwargs))
        context["social"] = Social.all_as_dict()

        news = Content.objects.filter(slug="noticias")
        if news.exists():
            context["content"] = news[0]

        return context
Exemple #22
0
    def get_context_data(self, **kwargs):
        np = get_newspaper(self.newspaper_id())
        year = get_year(self.year_id())

        context = ListView.get_context_data(self, **kwargs)
        context.update({
            "np": np,
            "year": year,
        })
        return context
Exemple #23
0
    def get_context_data(self):
        context = ListView.get_context_data(self)
        fpayee = Proposal.objects.filter(status="FPAYE")
        context['factPayee'] = fpayee
        total = 0
        for f in fpayee:
            total += f.amount()
        context['total'] = total

        return context
Exemple #24
0
    def get_context_data(self, *args, **kwargs):
        context = ListView.get_context_data(self, *args, **kwargs)
        context.update(BaseView.get_context_data(self, *args, **kwargs))
        context["partners"] = Partner.objects.all()

        content = Content.objects.filter(slug="parceiros")
        if content.exists():
            context["content"] = content[0]

        return context
Exemple #25
0
 def get_context_data(self, **kwargs):
     # Is this a bit of a hack? Use better inheritance?
     kwargs_article = ArticleMixin.get_context_data(self, **kwargs)
     kwargs_listview = ListView.get_context_data(self, **kwargs)
     kwargs["search_form"] = forms.SearchForm(self.request.GET)
     kwargs["query"] = self.query
     kwargs.update(kwargs_article)
     kwargs.update(kwargs_listview)
     kwargs["selected_tab"] = "attachments"
     return kwargs
Exemple #26
0
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)
        # context now has a key 'post_list' with the right queryset

        context['tag_list'] = BlogPost.published.get_tags_list(sort_name=True, relative=True)
        context['post_number'] = sum([x[1] for x in context['tag_list']])
        context['searched_tags'] = self.searched_tags
        context['searched_tags_raw'] = '+'.join(self.searched_tags)

        context['form'] = self.form
        return context
Exemple #27
0
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)

        context['lights'] = []
        for light in self.get_queryset():
            context['lights'].append({
                'light': light,
                'from': LightFom(instance=light)
            })

        return context
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)
        context['idproyecto'] = self.kwargs['idproyecto']
        context['E_APROBADO'] = SolicitudCambio.E_APROBADO
        context['E_RECHAZADO'] = SolicitudCambio.E_RECHAZADO
        context['E_ENVIADO'] = SolicitudCambio.E_ENVIADO
        context['E_TERMINADO'] = SolicitudCambio.E_TERMINADO
        context['E_BORRADOR'] = SolicitudCambio.E_BORRADOR
        

        return context
Exemple #29
0
    def get_context_data(self, *parg, **karg):
        """ Report missing authors and add extra information to each author """

        data = ListView.get_context_data(self, *parg, **karg)
        if not data["authors"]:
            data["info_message"] = "no authors are found."
        else:
            for author in data["authors"]:
                author.books = Book.objects.filter(author__in=(author.id,)).count()

        return data
Exemple #30
0
 def get_context_data(self, **kwargs):
     data = ListView.get_context_data(self, **kwargs)
     data.update({'report': self.report,
                 'title':self.report.verbose_name,
                 'rows':self.object_list,
                 'filter_form':self.get_filter_form(),
                 "aggregates":self.report_request.aggregates,
                 "cl":self.get_changelist(data),
                 'report_request':self.report_request,
                 "urlparams":urlencode(self.report_request.params)})
     return data
Exemple #31
0
    def get_context_data(self, **kwargs):
        """
        Add a list of filters and self.form to the context to be rendered by
        the view.
        """
        kwargs = ListView.get_context_data(self, **kwargs)
        kwargs["form"] = self.form
        kwargs["filters"] = self.get_filters()
        kwargs["stacked_fields"] = getattr(self, "stacked_fields", [])

        return kwargs
Exemple #32
0
    def get_context_data(self, **kwargs):
        np = get_newspaper(self.newspaper_id())
        year = get_year(self.year_id())
        issue = get_issue(np, year, self.issue_id())

        context = ListView.get_context_data(self, **kwargs)
        context.update({
            "np": np,
            "year": year,
            "issue": issue,
        })
        return context
Exemple #33
0
 def get_context_data(self, **kwargs):
     """Add context data for the template."""
     model = self.object_list.model._meta.model_name
     if model == 'thread':
         context = super().get_context_data(**kwargs)
     else:
         context = ListView.get_context_data(self, **kwargs)
     context['model'] = model
     context['query'] = self.query
     context['results_count'] = self.results_count
     context['query_url'] = 'q=' + self.query + '&'
     return context
Exemple #34
0
 def get_context_data(self, **kwargs):
     """Add context data for the template."""
     model = self.object_list.model._meta.model_name
     if model == 'thread':
         context = super().get_context_data(**kwargs)
     else:
         context = ListView.get_context_data(self, **kwargs)
     context['model'] = model
     context['query'] = self.query
     context['results_count'] = self.results_count
     context['query_url'] = 'q=' + self.query + '&'
     return context
Exemple #35
0
    def get_context_data(self, **kwargs):
        np = get_newspaper(self.newspaper_id())
        year = get_year(self.year_id())
        issue = get_issue(np, year, self.issue_id())

        context = ListView.get_context_data(self, **kwargs)
        context.update({
            "np": np,
            "year": year,
            "issue": issue,
        })
        return context
Exemple #36
0
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)
        if self.request.GET:
            form = self.form_class(data=self.request.GET)
        else:
            form = self.form_class()

        context['form'] = form

        if form.is_valid():
            context['report'] = self.get_report_sum()

        return context
 def get_context_data(self, **kwargs):
     data = ListView.get_context_data(self, **kwargs)
     data.update({
         'report': self.report,
         'title': self.report.verbose_name,
         'rows': self.object_list,
         'filter_form': self.get_filter_form(),
         "aggregates": self.report_request.aggregates,
         "cl": self.get_changelist(data),
         'report_request': self.report_request,
         "urlparams": urlencode(self.report_request.params)
     })
     return data
Exemple #38
0
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)
        if self.request.GET:
            form = self.form_class(data=self.request.GET)
        else:
            form = self.form_class()

        context['form'] = form

        if form.is_valid():
            context['report'] = self.get_report_sum()

        return context
Exemple #39
0
 def get_context_data(self, object_list, **kwargs):
     """
         Adds form and object list plus whatever else is passed as a kwarg
         to the context.
         :param object_list: list of :py:class:`Plan`s (actually queryset)
         """
     context = ListView.get_context_data(self, object_list=object_list)
     context.update(SubscribeMixin.get_context_data(self, **kwargs))
     if self.request.user.is_authenticated():
         try:
             context['current_user_subscription'] = self.request.user.subscription
         except Subscription.DoesNotExist:
             context['current_user_subscription'] = None
     return context
Exemple #40
0
 def get_context_data(self,*args,**kwargs):
     ctx=ListView.get_context_data(self,*args,**kwargs)
     # ret=[ (str(x),False,"year="+str(x)) for x in models.Photo.objects.get_years() ]
     ctx["filter_list"]=[]
     for f in self.filter_list:
         ctx["filter_list"].append({
             "name": f.name,
             "params": f.get_params(self.request.GET)
         })
     qcopy=self.request.GET.copy()
     if "page" in qcopy:
         qcopy.pop("page")
     ctx["parameters"]=qcopy.urlencode()
     return ctx
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     filter_form = self.get_filter_form()
     context['filter_form'] = filter_form
     valid_thesaurus_ids = [entry['thesaurus__id'] for entry in Term.objects.root_nodes().values('thesaurus__id').annotate(root_nodes_count=Count('thesaurus__id')).order_by().filter(root_nodes_count__lt=settings.JOCONDE_TERM_TREE_MAX_ROOT_NODE)]  # @UndefinedVariable
     context['term_tree_valid_thesaurus'] = json.dumps(valid_thesaurus_ids)
     if self.selected_thesaurus and self.can_display_level:
         if self.selected_thesaurus.id in valid_thesaurus_ids:
             context['show_levels'] = True
         else:
             context['show_levels'] = False
     else:
         context['show_level'] = False        
     return context
Exemple #42
0
    def get_context_data(self, **kwargs):
        kwargs_article = ArticleMixin.get_context_data(self, **kwargs)
        kwargs_listview = ListView.get_context_data(self, **kwargs)
        kwargs.update(kwargs_article)
        kwargs.update(kwargs_listview)
        kwargs['filter_query'] = self.query
        kwargs['filter_form'] = self.filter_form

        # Update each child's ancestor cache so the lookups don't have
        # to be repeated.
        updated_children = kwargs[self.context_object_name]
        for child in updated_children:
            child.set_cached_ancestors_from_parent(self.urlpath)
        kwargs[self.context_object_name] = updated_children

        return kwargs
Exemple #43
0
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)
        # Don't use super here to avoid multiple-inheritance issues

        queries = self.request.GET.copy()

        if 'page' in queries:
            del queries['page']

        context['show_create'] = False

        queries_encoded = queries.urlencode()
        context['queries_encoded'] = queries_encoded
        if hasattr(self, 'filterform'):
            context['filterform'] = self.filterform

        return context
Exemple #44
0
    def get_context_data(self, **kwargs):
        """
        In addition to the inherited get_context_data methods, populates a
        ``sort_links`` variable in the template context, which contains the
        querystring for the next sort if that option is chosen.

        For example, if the sort is by descending popularity, choosing the
        ``date`` option will sort by descending date, while choosing
        ``popular`` would switch to sorting by ascending popularity.

        """
        context = ListView.get_context_data(self, **kwargs)
        form = self._make_search_form(self._get_query(self.request))
        context['form'] = form
        form.is_valid()
        context['query'] = form.cleaned_data['q']

        sort, desc = self._process_sort(self._get_sort(self.request))
        sort_links = {}

        for s in self.sorts:
            querydict = self.request.GET.copy()
            querydict.pop('sort', None)
            querydict.pop('page', None)
            if s == sort:
                # Reverse the current ordering if the sort is active.
                querydict['sort'] = ''.join(('' if desc else '-', s))
            else:
                # Default to descending.
                querydict['sort'] = ''.join(('-', s))
            sort_links[s] = ''.join(('?', querydict.urlencode()))
        context['sort_links'] = sort_links

        context['filters'] = self._cleaned_filters
        context['filter_form'] = self.filter_form
        if self.url_filter in self._cleaned_filters:
            try:
                context[self.url_filter] = (
                    self._cleaned_filters[self.url_filter][0])
            except IndexError:
                # Then there are no items matching the url_filter - so we're
                # on a page that shouldn't exist.
                raise Http404

        return context
Exemple #45
0
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)
        # Don't use super here to avoid multiple-inheritance issues

        queries = self.request.GET.copy()

        if 'page' in queries:
            del queries['page']

        context['show_create'] = False

        queries_encoded = queries.urlencode()
        context['queries_encoded'] = queries_encoded
        if hasattr(self, 'filterform'):
            context['filterform'] = self.filterform



        return context
Exemple #46
0
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     context['filter_string'] = self.get_filter_string()
     context['caption'] = self.caption
     context['description'] = self.description
     if self.show_filter:
         u = FormMixin.get_context_data(self, **kwargs)
         context.update(u)
         context['description'] = 'Найдено {count} котиков'.format(
             count=len(self.object_list))
     else:
         context['description'] = self.description
         del context['form']
     extra_title = context['caption']
     context.update(
         get_base_catsekb_context(active_menu=ANIMALS,
                                  extra_title=extra_title,
                                  project=self.project))
     return context
Exemple #47
0
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     type_cat = self.kwargs.get('type')
     if type_cat:
         for key, value in self.model.TYPE_CHOICES:
             if int(key) == int(type_cat):
                 # cat = ({value: reverse('stock_discount_sub_list', kwargs={'type': type_cat})})
                 cat_name = value
                 cat_url = reverse('stock_discount_sub_list', kwargs={'type': type_cat})
     else:
         # cat=({u'Акции/Скидки':reverse('stock_discount_index')})
         cat_name = u'Акции/Скидки'
         cat_url = reverse('stock_discount_index')
     context.update(
         {
             'current_category': cat_name,
             'current_url': cat_url,
         }
     )
     return context
Exemple #48
0
 def get_context_data(self, **kwargs):
     kwargs.update(ArticleMixin.get_context_data(self, **kwargs))
     return ListView.get_context_data(self, **kwargs)
Exemple #49
0
 def get_context_data(self):
     context = ListView.get_context_data(self)
     context['devPerdus'] = Proposal.objects.filter(status="DPERD")
     context['factPayee'] = Proposal.objects.filter(status="FPAYE")
     return context
Exemple #50
0
 def get_context_data(self, **kwargs):
     return ListView.get_context_data(self, **kwargs)
Exemple #51
0
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     context.update({
         "np": get_newspaper(self.kwargs.get('np')),
     })
     return context
Exemple #52
0
 def get_context_data(self, **kwargs):
     context = AdminObjectView.get_context_data(self, **kwargs)
     context.update(ListView.get_context_data(self, **kwargs))
     return context
Exemple #53
0
 def get_context_data(self, **kwargs):
     data = ListView.get_context_data(self, **kwargs)
     data['breadcrumbs'] = breadcrumbs(
         ('projects.gsoc', 'Google Summer of Code Projects'), )
     return data
Exemple #54
0
 def get_context_data(self, *args, **kwargs):
     context = ListView.get_context_data(self, *args, **kwargs)
     context["choices"] = billStatus
     return context
Exemple #55
0
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     user = self.kwargs['username']
     customer = Customer.objects.get(user=user)
     context['rentMovie'] = MovieRent.objects.filter(customer=user)
     return context
Exemple #56
0
 def get_context_data(self):
     context = ListView.get_context_data(self)
     context['devEnCours'] = Proposal.objects.filter(status="DEVEC")
     context['factEnCours'] = Proposal.objects.filter(status="FACEC")
     return context
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     context["per_page"] = self.request.GET.get("per_page")
     return context