Пример #1
0
def language_detail(request, slug):
    language = get_object_or_404(Language, slug=slug)
    return  ListView.as_view(request,
                             queryset=language.snippet_set.all(),
                             paginate_by=20,
                             template_name='cab/language_detail.html',
                             extra_context={ 'language': language })
Пример #2
0
def show_user_list(request):
    if request.user.is_superuser:
        return ListView.as_view(request,
                paginate_by=10,
                queryset=User.objects.all(),
                template_name='users/user_list.html')
    raise Http404
Пример #3
0
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)

        context['global'] = self.get_global()
        context['producao_anual'] = self.get_producao_anual()

        return context
Пример #4
0
    def __init__(self):
        self.create = login_required(CreateView.as_view(
            model=self.model,
            fields=('name',),
            success_url=reverse_lazy('laboratory:laboratory_list'),
            template_name=self.template_name_base + 'form.html'
        ))

        self.edit = login_required(UpdateView.as_view(
            model=self.model,
            fields=('name',),
            success_url=reverse_lazy('laboratory:laboratory_list'),
            template_name=self.template_name_base + 'form.html'
        ))

        self.delete = login_required(DeleteView.as_view(
            model=self.model,
            success_url=reverse_lazy('laboratory:laboratory_list'),
            template_name=self.template_name_base + 'delete.html'
        ))

        self.list = login_required(ListView.as_view(
            model=self.model,
            paginate_by=10,
            template_name=self.template_name_base + 'list.html'
        ))
Пример #5
0
    def get_queryset(self):
        qs = ListView.get_queryset(self)

        qs = qs.filter(
            notificacoes__user=self.request.user
        ).order_by('notificacoes__read', '-created')
        return qs
Пример #6
0
 def get(self, request, *args, **kwargs):
     self.votingId = kwargs.get('voting_id')
     try:
         self.voting = Voting.objects.get(pk=self.votingId)
     except ObjectDoesNotExist as n:
         return redirect('census_list')
     return ListView.get(self, request, *args, **kwargs)
Пример #7
0
    def get_queryset(self):
        qs = ListView.get_queryset(self)

        qs = qs.filter(
            notificacoes__user=self.request.user
        ).order_by('notificacoes__read', '-created')
        return qs
Пример #8
0
    def __init__(self):
        self.create = login_required(
            CreateView.as_view(
                model=self.model,
                fields=('name', ),
                success_url=reverse_lazy('laboratory:laboratory_list'),
                template_name=self.template_name_base + 'form.html'))

        self.edit = login_required(
            UpdateView.as_view(
                model=self.model,
                fields=('name', ),
                success_url=reverse_lazy('laboratory:laboratory_list'),
                template_name=self.template_name_base + 'form.html'))

        self.delete = login_required(
            DeleteView.as_view(
                model=self.model,
                success_url=reverse_lazy('laboratory:laboratory_list'),
                template_name=self.template_name_base + 'delete.html'))

        self.list = login_required(
            ListView.as_view(model=self.model,
                             paginate_by=10,
                             template_name=self.template_name_base +
                             'list.html'))
Пример #9
0
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     # get author id from URL the get all books by this author
     context['book_list'] = Book.objects.filter(author_id=self.kwargs['pk'])
     # get author object
     context['author'] = Author.objects.get(id=self.kwargs['pk'])
     return context
Пример #10
0
def user_bookmarks(request):
    return ListView.as_view(
        request,
        queryset=Bookmark.objects.filter(user__pk=request.user.id),
        template_name="cab/user_bookmarks.html",
        paginate_by=20,
    )
Пример #11
0
 def dispatch(self, request, *args, **kwargs):
     try:
         self.mode = request.GET.get('m')
     except (TypeError, ValueError):
         pass
     
     return ListView.dispatch(self, request, *args, **kwargs)
Пример #12
0
def archive(request):
    return ListView.as_view(
        model=Post,
        queryset=Post.objects.published().select_related(),
        paginate_by=POSTS_PER_PAGE,
        context_object_name="post",
    )
Пример #13
0
 def get_context_data(self, **kwargs):
     if hasattr(site_settings,'PRIVATE_WIKI') and site_settings.PRIVATE_WIKI and self.request.user.is_anonymous():
         raise Http404()
     kwargs = ListView.get_context_data(self, **kwargs)
     kwargs['search_form'] = self.search_form
     kwargs['search_query'] = self.query
     return kwargs
Пример #14
0
 def get_context_data(self, **kwargs):
     ctx = ListView.get_context_data(self, **kwargs)
     ctx['invitations'] = CourseInvitation.objects.filter(
         course=self.request.course)
     ctx['blocked'] = settings.BLOCKED_EMAIL_DOMAINS
     ctx['can_edit'] = allow_roster_changes(self.request.course)
     return ctx
Пример #15
0
    def get_context_data(self, **kwargs):
        context = {}
        context['object'] = self.object

        if self.object:
            context['subnav_template_name'] = 'sigad/subnav_classe.yaml'

        return ListView.get_context_data(self, **context)
Пример #16
0
 def get_context_data(self, **kwargs):
     ctx = ListView.get_context_data(self, **kwargs)
     ctx['course'] = self.request.course
     ctx['invitations'] = CourseInvitation.objects.filter(
         course=self.request.course)
     ctx['blocked'] = settings.BLOCKED_EMAIL_DOMAINS
     ctx['can_edit'] = allow_roster_changes(self.request.course)
     return ctx
Пример #17
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
Пример #18
0
    def get_context_data(self, **kwargs):
        context = {}
        context['object'] = self.object

        if self.object:
            context['subnav_template_name'] = 'sigad/subnav_classe.yaml'

        return ListView.get_context_data(self, **context)
Пример #19
0
    def get(self, request, *args, **kwargs):
        """
        Goes here when loading page
        """
        self.object = None
        self.form = self.get_form(self.form_class)

        return ListView.get(self, request, *args, **kwargs)
Пример #20
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
Пример #21
0
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)

        base = reverse('streamlogs-detail')
        context['base_url'] = u'{}?page='.format(base)
        context['page'] = self.request.GET.get('page', '1')

        return context
Пример #22
0
 def get_context_data(self, **kwargs):
     context = ListView.get_context_data(self, **kwargs)
     pk = int(self.kwargs.get('pk'))
     screen = get_object_or_404(Screen, pk=pk)
     context['screen'] = screen
     network = screen.well.network
     context['network'] = network
     return context
Пример #23
0
 def get_context_data(self, **kwargs):
     ''' Include today's date. 
     
     Should be a middleware now, since am using it twice.
     But I don't care.
     '''
     context = ListView.get_context_data(self, **kwargs)
     context['today'] = datetime.today().strftime(DATE_FORMAT)
     return context
Пример #24
0
    def post(self, request, *args, **kwargs):
        self.object = None
        self.form = self.get_form(self.form_class)

        if self.form.is_valid():
            self.form.save()
            return redirect('/register/success/')
        else:
            return ListView.get(self, request, *args, **kwargs)
Пример #25
0
    def get(self, request, *args, **kwargs):
        self.lab = kwargs['lab_pk']
        self.request_format = request.GET.get('format', 'html')

        if self.request_format=='html':
            return djListView.get(self, request, *args, **kwargs)
        if hasattr(self, 'get_'+self.request_format):
            return getattr(self, 'get_'+self.request_format)(request, *args, **kwargs)
        raise Http404()
Пример #26
0
        def get_queryset(self):
            qs = ListView.get_queryset(self)

            if not self.request.user.pk or not AreaTrabalho.objects.filter(
                    operadores=self.request.user.pk).exists():
                qs = qs.filter(workspace__tipo=AreaTrabalho.TIPO_PUBLICO)
            else:
                qs = qs.filter(workspace__operadores=self.request.user.pk)
            return qs
Пример #27
0
 def render_to_response(self, context, **response_kwargs):
     
     default_context = {
         'title': self.site.name + ' - ' + config.META_DESCRIPTION,
         'meta_description': config.META_DESCRIPTION,
     }
     new_context = {**default_context,  **context}
     
     return ListView.render_to_response(self, new_context, **response_kwargs)
Пример #28
0
def tag_list(request):
    ct = ContentType.objects.get_for_model(Post)
    return ListView.as_view(
        model=Tag,
        queryset=Tag.objects.filter(items__content_type=ct),
        paginate_by=POSTS_PER_PAGE,
        template_name="blogdor/tag_list.html",
        context_object_name="tag",
    )
Пример #29
0
        def get_queryset(self):
            qs = ListView.get_queryset(self)

            if not self.request.user.pk or not AreaTrabalho.objects.filter(
                    operadores=self.request.user.pk).exists():
                qs = qs.filter(workspace__tipo=AreaTrabalho.TIPO_INSTITUCIONAL)
            else:
                qs = qs.filter(workspace__operadores=self.request.user.pk)
            return qs
Пример #30
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'] = 'template'
     return kwargs
Пример #31
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'
     if hasattr(site_settings,'PRIVATE_WIKI') and site_settings.PRIVATE_WIKI and self.request.user.is_anonymous():
         raise Http404()
     return kwargs
Пример #32
0
def deck_list(request):
    decks = Deck.objects.filter(owner=request.user,
                                active=True).order_by('name')
    context = {'container_id': 'deckDialog'}
    context['only_one_deck_exists'] = (len(decks) == 1)

    return ListView.as_view(request,
                            queryset=decks,
                            extra_context=context,
                            template_object_name='deck')
Пример #33
0
 def get_context_data(self, **kargs):
     context = ListView.get_context_data(self, **kargs)
     context["lights"] = []
     for light in self.get_queryset():
         context["lights"].append({
             "light": light,
             "form": LightForm(instance=light)
         })
     context['allLight'] = LightForm(instance=light)
     return context
Пример #34
0
 def dispatch(self, request, *args, **kwargs):
     try:
         self.mode = request.GET.get('m')
         self.ordering = request.GET.get('o')
     except (TypeError, ValueError):
         pass
     if self.mode == 'a': # return ajax/json
         self.paginate_by = 0
     
     return ListView.dispatch(self, request, *args, **kwargs)
Пример #35
0
 def __init__(self, **kwargs):
     ListView.__init__(self, **kwargs)
     if Tema.objects.all():
         tema = Tema.objects.all()[0]
         tema.set_main_color(tema.cor_home)
     else:
         tema = Tema(cor_principal='#0088cc',\
                 cor_home='#0088cc',\
                 cor_academico='#0088cc',\
                 cor_profissional='#0088cc',\
                 cor_complementar='#0088cc',\
                 cor_competencias='#0088cc',\
                 cor_informacoes='#0088cc',\
                 cor_fonte_padrao='#30353A',\
                 fonte_padrao='"Helvetica Neue", sans-serif',\
                 sideleft_width='250')
         tema.save()
         tema = Tema.objects.all()[0]
         tema.set_main_color(tema.cor_home)
Пример #36
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
Пример #37
0
    def listAvailItems(self):
        displayInConsole(self)

        visibleItems = []

        for item in ListView.get_queryset(self):
            if item.isAvailableFor(self.request.user, 'visibility'):
                visibleItems.append(item.id)

        return visibleItems
Пример #38
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
Пример #39
0
def announcement_list(request):
    """
    A basic view that wraps ``django.views.list_detail.object_list`` and
    uses ``current_announcements_for_request`` to get the current
    announcements.
    """
    queryset = current_announcements_for_request(request)
    return ListView.as_view(request, **{
        "queryset": queryset,
        "allow_empty": True,
    })
Пример #40
0
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)

        base = reverse('streamlogs-list')
        context['base_url'] = u'{}?page='.format(base)
        context['q'] = self.request.GET.get('q', '')
        context['sort_by'] = self.request.GET.get('sort_by', 'request_at')
        context['direction'] = self.request.GET.get('direction', 'desc')
        context['page'] = self.request.GET.get('page', '1')

        return context
Пример #41
0
def _relationship_list(request, queryset, template_name=None, *args, **kwargs):
    return ListView.object_list(
        request=request,
        queryset=queryset,
        paginate_by=20,
        page=int(request.GET.get('page', 0)),
        template_object_name='relationship',
        template_name=template_name,
        *args,
        **kwargs
    )
Пример #42
0
def tagged_object_list(request, slug, queryset, **kwargs):
    if callable(queryset):
        queryset = queryset()
    tag = get_object_or_404(Tag, slug=slug)
    qs = queryset.filter(pk__in=TaggedItem.objects.filter(
        tag=tag, content_type=ContentType.objects.get_for_model(queryset.model)
    ).values_list("object_id", flat=True))
    if "extra_context" not in kwargs:
        kwargs["extra_context"] = {}
    kwargs["extra_context"]["tag"] = tag
    return ListView.as_view(request, qs, **kwargs)
Пример #43
0
def profile_list(request,
                 public_profile_field=None,
                 template_name='profiles/profile_list.html',
                 **kwargs):

    profile_model = utils.get_profile_model()
    queryset = profile_model._default_manager.all()
    if public_profile_field is not None:
        queryset = queryset.filter(**{public_profile_field: True})
    kwargs['queryset'] = queryset
    return ListView.as_view(request, template_name=template_name, **kwargs)
Пример #44
0
    def dispatch(self, request, *args, **kwargs):
        self.object = None
        if 'pk' in self.kwargs:
            self.object = get_object_or_404(Classe, pk=self.kwargs['pk'])

            has_permission = self.has_permission()

            if not has_permission:
                if not request.user.is_superuser and \
                        self.object.visibilidade != Classe.STATUS_PUBLIC:
                    has_permission = False

                    # FIXME: refatorar e analisar apartir de self.object
                    pubs = Classe.objects.filter(
                        visibilidade=Classe.STATUS_PUBLIC).select_related(
                        'parent', 'parent__parent')
                    for pub in pubs:
                        parents = pub.parents
                        for p in parents[::-1]:
                            if p == self.object:
                                has_permission = True
                                break
                        if has_permission:
                            break

                    if not has_permission and not request.user.is_anonymous():
                        if (self.object.visibilidade ==
                                Classe.STATUS_PRIVATE and
                                self.object.owner != request.user):
                            has_permission = False
                        else:
                            pr = self.permission_required.split('.')
                            puc_list = PermissionsUserClasse.objects.filter(
                                user=request.user,
                                permission__content_type__app_label=pr[0],
                                permission__codename=pr[1]).select_related(
                                    'classe__parent', 'classe__parent__parent')
                            for puc in puc_list:
                                if puc.classe == self.object:
                                    has_permission = True
                                    break

                                parents = puc.classe.parents
                                for p in parents[::-1]:
                                    if p == self.object:
                                        has_permission = True
                                        break
                                if has_permission:
                                    break
                    if not has_permission:
                        return self.handle_no_permission()

        return ListView.dispatch(self, request, *args, **kwargs)
Пример #45
0
 def dispatch(self, request, *args, **kwargs):
     try:
         self.site = get_current_site(request)
         self.query = request.GET.get("q")
         self.type = request.GET.get("c")
         self.mode = request.GET.get('m')
         self.paginate_by = int(request.GET.get('s'))
         self.lang = request.LANGUAGE_CODE
     except (TypeError, ValueError):
         pass
     
     return ListView.dispatch(self, request, *args, **kwargs)
Пример #46
0
    def dispatch(self, request, *args, **kwargs):
        self.object = None
        if 'pk' in self.kwargs:
            self.object = get_object_or_404(Classe, pk=self.kwargs['pk'])

            has_permission = self.has_permission()

            if not has_permission:
                if not request.user.is_superuser and \
                        self.object.visibilidade != Classe.STATUS_PUBLIC:
                    has_permission = False

                    # FIXME: refatorar e analisar apartir de self.object
                    pubs = Classe.objects.filter(
                        visibilidade=Classe.STATUS_PUBLIC).select_related(
                        'parent', 'parent__parent')
                    for pub in pubs:
                        parents = pub.parents
                        for p in parents[::-1]:
                            if p == self.object:
                                has_permission = True
                                break
                        if has_permission:
                            break

                    if not has_permission and not request.user.is_anonymous():
                        if (self.object.visibilidade ==
                                Classe.STATUS_PRIVATE and
                                self.object.owner != request.user):
                            has_permission = False
                        else:
                            pr = self.permission_required.split('.')
                            puc_list = PermissionsUserClasse.objects.filter(
                                user=request.user,
                                permission__content_type__app_label=pr[0],
                                permission__codename=pr[1]).select_related(
                                    'classe__parent', 'classe__parent__parent')
                            for puc in puc_list:
                                if puc.classe == self.object:
                                    has_permission = True
                                    break

                                parents = puc.classe.parents
                                for p in parents[::-1]:
                                    if p == self.object:
                                        has_permission = True
                                        break
                                if has_permission:
                                    break
                    if not has_permission:
                        return self.handle_no_permission()

        return ListView.dispatch(self, request, *args, **kwargs)
Пример #47
0
 def get_context_data(self, **kwargs):
     contex_data = ListView.get_context_data(self, **kwargs)
     process = get_object_or_404(Process, pk=self.kwargs['process_id'], owner=self.request.user)
     contex_data['process'] = process;
     # if process.validates:
     #     contex_data['prev_process_id'] = process.validates.task.process.pk
     #     contex_data['prev_task_id'] = process.validates.task.pk
     # #        check if it's bpmn providded and put th epicutre here
     # bpmnprocess = process.processactiviti
     #        if bpmnprocess is not None:
     #            contex_data['picture']='ciao'
     return contex_data
Пример #48
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'
     # try:  # TODO: remove
     #     kwargs['metadataRevisions'] = SupersenseRevision.objects.all()
     # except:
     #     pass
     return kwargs
Пример #49
0
def profile_list(request,
                 public_profile_field=None,
                 template_name='profiles/profile_list.html',
                 **kwargs):
    """
    A list of user profiles.

    If no profile model has been specified in the
    ``AUTH_PROFILE_MODULE`` setting,
    ``django.contrib.auth.models.SiteProfileNotAvailable`` will be
    raised.

    **Optional arguments:**

    ``public_profile_field``
        The name of a ``BooleanField`` on the profile model; if the
        value of that field on a user's profile is ``False``, that
        profile will be excluded from the list. Use this feature to
        allow users to mark their profiles as not being publicly
        viewable.

        If this argument is not specified, it will be assumed that all
        users' profiles are publicly viewable.

    ``template_name``
        The name of the template to use for displaying the profiles. If
        not specified, this will default to
        :template:`profiles/profile_list.html`.

    Additionally, all arguments accepted by the
    :view:`django.views.generic.list_detail.object_list` generic view
    will be accepted here, and applied in the same fashion, with one
    exception: ``queryset`` will always be the ``QuerySet`` of the
    model specified by the ``AUTH_PROFILE_MODULE`` setting, optionally
    filtered to remove non-publicly-viewable proiles.

    **Context:**

    Same as the :view:`django.views.generic.list_detail.object_list`
    generic view.

    **Template:**

    ``template_name`` keyword argument or
    :template:`profiles/profile_list.html`.

    """
    profile_model = utils.get_profile_model()
    queryset = profile_model._default_manager.all()
    if public_profile_field is not None:
        queryset = queryset.filter(**{public_profile_field: True})
    kwargs['queryset'] = queryset
    return ListView.as_view()(request, template_name=template_name, **kwargs)
Пример #50
0
    def post(self, request, *args, **kwargs):
        self.object = None
        self.form = self.get_form(self.form_class)

        if self.form.is_valid():
            postid = self.kwargs['postid']
            postinstance = SDLPost.objects.get(postid=postid)
            user = self.request.user
            self.form.save(postinstance, user)
            url = '/selfdirected/view/' + postid
            return redirect(url)
        else:
            return ListView.get(self, request, *args, **kwargs)
Пример #51
0
 def get_context_data(self, **kwargs):
     contex_data = ListView.get_context_data(self, **kwargs)
     task = get_object_or_404(Task, pk=self.kwargs['task_id'], owner=self.request.user)
     contex_data['task'] = task
     #        if task.process.title.startswith("[V]"):
     #            id_process = task.process.title.lstrip("[V] Validation for ")
     #            process = get_object_or_404(Process, pk=self.kwargs['process_id'], owner=self.request.user)
     #
     #            contex_data['process'] = task
     #        else:
     process = get_object_or_404(Process, pk=self.kwargs['process_id'], owner=self.request.user)
     contex_data['process'] = process
     return contex_data
Пример #52
0
    def get_context_data(self, **kwargs):
        slug = self.kwargs['slug']
#        kwargs['option_name_list'] = OptionName.objects.filter(
#                                       producttype__slug=slug).values_list(
#                                       'name', flat=True)
        kwargs['product_list'] = Product.objects.filter(
                    product_type__slug=slug).select_related().prefetch_related(
          'productvariation_set', 'productvariation_set__images',
          'productvariation_set__optionvalue_set__product_type_option_name',
          'productvariation_set__optionvalue_set', 'images',
          'product_type__option_name'
          )
        return ListView.get_context_data(self, **kwargs)
Пример #53
0
    def post(self, request, *args, **kwargs):
        """
        Save form data if valid; 
        return empty form if valid or old form with error if not
        """
        self.object = None
        self.form = self.get_form(self.form_class)

        if self.form.is_valid():
            self.form.save()
            self.form = NoteForm()

        return ListView.get(self, request, *args, **kwargs)
def profile_list(request, public_profile_field=None,
                 template_name='profiles/profile_list.html', **kwargs):
    """
    A list of user profiles.
    
    If no profile model has been specified in the
    ``AUTH_PROFILE_MODULE`` setting,
    ``django.contrib.auth.models.SiteProfileNotAvailable`` will be
    raised.

    **Optional arguments:**

    ``public_profile_field``
        The name of a ``BooleanField`` on the profile model; if the
        value of that field on a user's profile is ``False``, that
        profile will be excluded from the list. Use this feature to
        allow users to mark their profiles as not being publicly
        viewable.
        
        If this argument is not specified, it will be assumed that all
        users' profiles are publicly viewable.
    
    ``template_name``
        The name of the template to use for displaying the profiles. If
        not specified, this will default to
        :template:`profiles/profile_list.html`.

    Additionally, all arguments accepted by the
    :view:`django.views.generic.list_detail.object_list` generic view
    will be accepted here, and applied in the same fashion, with one
    exception: ``queryset`` will always be the ``QuerySet`` of the
    model specified by the ``AUTH_PROFILE_MODULE`` setting, optionally
    filtered to remove non-publicly-viewable proiles.
    
    **Context:**
    
    Same as the :view:`django.views.generic.list_detail.object_list`
    generic view.
    
    **Template:**
    
    ``template_name`` keyword argument or
    :template:`profiles/profile_list.html`.
    
    """
    profile_model = utils.get_profile_model()
    queryset = profile_model._default_manager.all()
    if public_profile_field is not None:
        queryset = queryset.filter(**{ public_profile_field: True })
    kwargs['queryset'] = queryset
    return ListView.as_view(request, template_name=template_name, **kwargs)
Пример #55
0
 def post(self, request, *args, **kwargs): #We took the inputs of the form
     voter_id = kwargs.get('voter_id')
     datos = request.POST
     try:
         if(bool(datos['startDate'])):
             votingIds = Voting.objects.filter(start_date__gte=datos['startDate']).filter(end_date__lte=datos['endDate']).values('id')
             self.ids = Census.objects.filter(voting_id__in=votingIds).filter(voter_id=voter_id).values('voting_id')
         else:
             votingIds = Voting.objects.filter(name__iregex=datos['votingName']).values('id')
             self.ids = Census.objects.filter(voting_id__in=votingIds).filter(voter_id=voter_id).values('voting_id')
     except ObjectDoesNotExist as n:
         return redirect('census_list')  
     self.objects = Voting.objects.filter(pk__in=self.ids)
     return ListView.get(self, request, *args, **kwargs)
Пример #56
0
def group_preference_list(request, timetable_id=None):
    if timetable_id is not None:
        t = Timetable.objects.get(id=timetable_id)
        if timetable_visible(request, t):
            q = t.groups
        else:
            q = Group.objects.none()
    else:
        q = Group.objects.all()
    return ListView(
        request,
        queryset=q,
        template_name="friprosveta/group_list.html",
    ).as_view()
Пример #57
0
 def get(self, request, *args, **kwargs):
     voter_id = kwargs.get('voter_id')
     orden = kwargs.get('orden')
     ids = Census.objects.filter(voter_id=voter_id).values('voting_id')
     if(orden == 'name'):
         print('name')
         object_list = Voting.objects.filter(pk__in=ids).order_by('name')
     elif (orden == 'startDate'):
         print('start')
         object_list = Voting.objects.filter(pk__in=ids).order_by('start_date')
     else:
         print('end')
         object_list = Voting.objects.filter(pk__in=ids).order_by('end_date')
     self.objects = object_list
     return ListView.get(self, request, *args, **kwargs)
Пример #58
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
Пример #59
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