コード例 #1
0
ファイル: views.py プロジェクト: manlan2/ionyweb
def index_view(request, page_app, album_slug=None):
    """
    Display all albums of the app gallery.
    """
    context_instance=RequestContext(request)

    # Index View -- Display all albums
    if not album_slug:
        return render_view('page_gallery_images/index.html',
                           {'object': page_app},
                           RENDER_MEDIAS,
                           context_instance=context_instance)

    # Album View -- Display all images
    else:
        album = get_object_or_404(Album, slug=album_slug)
        # Displaying infos
        infos = {}
        if page_app.show_album_title:
            infos['title'] = album.title
            infos['title_rule'] = page_app.album_title_rule
        # --
        # Save object title in request
        # for plugin 'Breadcrumb'
        # --
        if settings.BREADCRUMB_PLUGIN in settings.INSTALLED_APPS:
            setattr(request, settings.BREADCRUMB_OBJECT_TITLE, album.title)
        # --
        return render_view('page_gallery_images/album.html',
                           {'object': page_app,
                            'infos': infos,
                            'album': album},
                           RENDER_MEDIAS,
                           title=album.title,
                           context_instance=context_instance)
コード例 #2
0
ファイル: views.py プロジェクト: ionyse/ionyweb
def index_view(request, page_app, year=None, month=None, day=None):

    if year is None:
        today = datetime.date.today()
        month = today.month
        year = today.year
        return HttpResponseRedirect('p/%d/%s/' % (year, str(month).zfill(2)))
    else:
        year = int(year)
        month = int(month)

    prev_year = year-1
    next_year = year+1
    
    prev_month = (month-2) % 12 + 1
    next_month = (month) % 12 + 1

    events = page_app.get_events_for_date(year, month, day)
    url = page_app.get_absolute_url()

    return render_view('page_agenda/index.html',
                       {'object': page_app,
                        'events': events,
                        'url': url,
                        'month': month,
                        'year': year,
                        'prev_month': prev_month,
                        'next_month': next_month,
                        'prev_year': prev_year,
                        'next_year': next_year,
                        },
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #3
0
def index_view(request, page_app):
    if page_app.url != '':
        return HttpResponseRedirect(page_app.url)
    else:
        return render_view('page_redirect/configuration.html',
                           {'app': page_app},
                           context_instance=RequestContext(request))
コード例 #4
0
ファイル: views.py プロジェクト: ionyse/ionyweb
def index_view(request, plugin):
    
    return render_view(
        plugin.get_templates('plugin_blog_entries_list/index.html'),
        {'object': plugin},
        RENDER_MEDIAS,
        is_admin_view=request.is_admin)
コード例 #5
0
def index_view(request, plugin):
    return render_view('plugin_subpages/index.html', {
        'object': plugin,
        'pages': request.page.get_children()
    },
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #6
0
ファイル: views.py プロジェクト: makinacorpus/coop-mes
def index_view(request, plugin):
    return render_view(
        "plugin_subpages/index.html",
        {"object": plugin, "pages": request.page.get_children()},
        MEDIAS,
        context_instance=RequestContext(request),
    )
コード例 #7
0
def index_view(request, plugin):

    return render_view(
        plugin.get_templates('plugin_blog_entries_list/index.html'),
        {'object': plugin},
        RENDER_MEDIAS,
        is_admin_view=request.is_admin)
コード例 #8
0
ファイル: views.py プロジェクト: ionyse/ionyweb
def index_view(request, plugin):
    
    return render_view(
        plugin.get_templates('plugin_slideshow/index.html'),
        {'object': plugin,
         'slides_list': plugin.slides_list},
        RENDER_MEDIAS, is_admin_view=request.is_admin)
コード例 #9
0
ファイル: views.py プロジェクト: manlan2/ionyweb
def index_view(request, plugin):

    separator = plugin.get_separator()
    links = plugin.links_enabled

    pages = []
    # Ancestors
    if plugin.ancestors_displayed:
        pages = list(request.page.get_ancestors())

    breadcrumb_items = []
    for page in pages:
        if links:
            item_str = u'<a href="%s">%s</a>' % (page.get_absolute_url(),
                                                 page.title)
        else:
            item_str = page.title
        breadcrumb_items.append(item_str)
    # Add current page
    breadcrumb_items.append(request.page.title)

    if hasattr(request, settings.BREADCRUMB_OBJECT_TITLE):
        breadcrumb_items.append(
            getattr(request, settings.BREADCRUMB_OBJECT_TITLE))

    return render_view(plugin.get_templates('plugin_breadcrumb/index.html'), {
        'object': plugin,
        'items': breadcrumb_items,
        'separator': separator
    })
コード例 #10
0
ファイル: views.py プロジェクト: makinacorpus/ionyweb
def index_view(request, plugin):
    
    separator = plugin.get_separator()
    links = plugin.links_enabled

    pages = []
    # Ancestors
    if plugin.ancestors_displayed:
        pages = list(request.page.get_ancestors())

    breadcrumb_items = []
    for page in pages:
        if links:
            item_str = u'<a href="%s">%s</a>' % (page.get_absolute_url(), page.title)
        else:
            item_str = page.title
        breadcrumb_items.append(item_str)
    # Add current page
    # Make the current page as a link if option enable
    if links:
        item_str = u'<a href="%s">%s</a>' % (request.page.get_absolute_url(), request.page.title)
        breadcrumb_items.append(item_str)
    else:
        breadcrumb_items.append(request.page.title)

    if hasattr(request, settings.BREADCRUMB_OBJECT_TITLE):
        breadcrumb_items.append(getattr(request, settings.BREADCRUMB_OBJECT_TITLE))

    return render_view(plugin.get_templates('plugin_breadcrumb/index.html'),
                       {'object': plugin,
                        'items': breadcrumb_items,
                        'separator': separator})
コード例 #11
0
ファイル: views.py プロジェクト: ionyse/fimu
def index_view(request, page_app):
    liste = ['Tata', 'titi', 'toto']
    return render_view('page_group/index.html',
                       { 'object': page_app,
                         'ma_liste': liste },
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #12
0
def index_view(request, page_app, year=None, month=None, day=None):

    if year is None:
        today = datetime.date.today()
        month = today.month
        year = today.year
        return HttpResponseRedirect('p/%d/%s/' % (year, str(month).zfill(2)))
    else:
        year = int(year)
        month = int(month)

    prev_year = year - 1
    next_year = year + 1

    prev_month = (month - 2) % 12 + 1
    next_month = (month) % 12 + 1

    events = page_app.get_events_for_date(year, month, day)
    url = page_app.get_absolute_url()

    return render_view('page_agenda/index.html', {
        'object': page_app,
        'events': events,
        'url': url,
        'month': month,
        'year': year,
        'prev_month': prev_month,
        'next_month': next_month,
        'prev_year': prev_year,
        'next_year': next_year,
    },
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #13
0
def index_view(request, page_app):
    base_url = u'%s' % (page_app.get_absolute_url())

    exchanges = Exchange.objects.all()

    if request.method == 'POST': # If the form has been submitted        
        # TODO: other filters
        form = PageApp_CoopExchangeForm(request.POST)
        if form.is_valid():
            if form.cleaned_data['free_search']:
                exchanges = exchanges.filter(Q(title__contains=form.cleaned_data['free_search']) | Q(description__contains=form.cleaned_data['free_search']))
            
            if form.cleaned_data['type_exchange']:
                exchanges = exchanges.filter(Q(eway__in=form.cleaned_data['type_exchange']))

            if form.cleaned_data['type']:
                exchanges = exchanges.filter(Q(etype__in=form.cleaned_data['type']))

    else:
        form = PageApp_CoopExchangeForm() # An empty form
    
    center_map = settings.COOP_MAP_DEFAULT_CENTER
    
    rdict = {'exchanges': exchanges, 'base_url': base_url, 'form': form, 'center': center_map}
    
    return render_view('page_coop_exchange/index.html',
                       rdict,
                       MEDIAS,
                       context_instance=RequestContext(request))                           
コード例 #14
0
ファイル: views.py プロジェクト: manlan2/ionyweb
def index_view(request, page_app):

    return render_view('page_book/index.html', {
        'object': page_app,
        'references': page_app.references,
    },
                       RENDER_MEDIAS,
                       is_admin_view=request.is_admin)
コード例 #15
0
def index_view(request, plugin):

    return render_view(plugin.get_templates('plugin_slideshow/index.html'), {
        'object': plugin,
        'slides_list': plugin.slides_list
    },
                       RENDER_MEDIAS,
                       is_admin_view=request.is_admin)
コード例 #16
0
def detail_view(request, page_app, pk):
    event = get_object_or_404(Event, pk=pk)
    base_url = u'%sp/' % (page_app.get_absolute_url())
    rdict = {'object': page_app, 'e': event, 'media_path': settings.MEDIA_URL, 'base_url': base_url}
    return render_view('page_coop_agenda/detail.html',
                       rdict,
                       MEDIAS,
                       context_instance=RequestContext(request))                              
コード例 #17
0
ファイル: views.py プロジェクト: geonux/coop-mes
 def render_to_response(self, context, **response_kwargs):
     assert response_kwargs == {}
     context['titles'] = self.titles
     context['title'] = context['titles'][self.step]
     return render_view(self.get_template_names(),
         context,
         ORGANIZATION_MEDIA,
         context_instance=RequestContext(self.request))
コード例 #18
0
 def ionyweb_view(request, page_app, **kwargs2):
     kwargs.update(kwargs2)
     response = view(request, **kwargs)
     if isinstance(response, HttpResponseRedirect):
         return response
     response.render()
     return render_view('content.html', {'content': response.content}, (),
                        context_instance=RequestContext(request))
コード例 #19
0
ファイル: views.py プロジェクト: geonux/coop-mes
 def ionyweb_view(request, page_app, **kwargs2):
     kwargs.update(kwargs2)
     response = view(request, **kwargs)
     if isinstance(response, HttpResponseRedirect):
         return response
     response.render()
     return render_view('content.html', {'content': response.content}, (),
         context_instance=RequestContext(request))
コード例 #20
0
ファイル: views.py プロジェクト: makinacorpus/coop-mes
def index_view(request, plugin):
    form = OrgSearch(request.GET)
    return render_view(
        "plugin_home_search/index.html",
        {"object": plugin, "form": form, "REGION_LABEL": settings.REGION_LABEL},
        MEDIAS,
        context_instance=RequestContext(request),
    )
コード例 #21
0
 def render_to_response(self, context, **response_kwargs):
     assert response_kwargs == {}
     context['titles'] = self.titles
     context['title'] = context['titles'][self.step]
     return render_view(self.get_template_names(),
                        context,
                        ORGANIZATION_MEDIA,
                        context_instance=RequestContext(self.request))
コード例 #22
0
ファイル: views.py プロジェクト: tominardi/ionyweb
def index_view(request, page_app):

    return render_view(
        "page_book/index.html",
        {"object": page_app, "references": page_app.references},
        RENDER_MEDIAS,
        is_admin_view=request.is_admin,
    )
コード例 #23
0
ファイル: views.py プロジェクト: geonux/coop-mes
def detail_view(request, page_app, pk):
    call = get_object_or_404(CallForTenders, pk=pk)
    get_params = request.GET.copy()
    return render_view('page_calls/detail.html',
                       {'object': page_app, 'call': call,
                        'get_params': get_params.urlencode()},
                       (),
                       context_instance=RequestContext(request))
コード例 #24
0
ファイル: views.py プロジェクト: makinacorpus/coop-mes
def detail_view(request, page_app, pk):
    call = get_object_or_404(CallForTenders, pk=pk)
    get_params = request.GET.copy()
    return render_view('page_calls/detail.html', {
        'object': page_app,
        'call': call,
        'get_params': get_params.urlencode()
    }, (),
                       context_instance=RequestContext(request))
コード例 #25
0
def index_view(request, plugin):
    form = OrgSearch(request.GET)
    return render_view('plugin_home_search/index.html', {
        'object': plugin,
        'form': form,
        'REGION_LABEL': settings.REGION_LABEL
    },
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #26
0
ファイル: views.py プロジェクト: geonux/coop-mes
def detail_view(request, page_app, pk):
    org = get_object_or_404(Organization, pk=pk, status=ORGANIZATION_STATUSES.VALIDATED)
    calls = org.callfortenders_set.filter(deadline__gte=now()).order_by('deadline')
    get_params = request.GET.copy()
    return render_view('page_directory/detail.html',
                       {'object': page_app, 'org': org, 'calls': calls,
                        'get_params': get_params.urlencode()},
                       (),
                       context_instance=RequestContext(request))
コード例 #27
0
ファイル: views.py プロジェクト: makinacorpus/coop-mes
def index_view(request, plugin):
    news = Entry.objects.filter(status=Entry.STATUS_ONLINE)
    news = news.filter(a_la_une=True).order_by('-publication_date')
    orgs = Organization.objects.filter(status=ORGANIZATION_STATUSES.VALIDATED)
    orgs = orgs.filter(a_la_une=True).order_by('-validation')
    return render_view('plugin_last_news/index.html',
                       {'object': plugin, 'news': news, 'orgs': orgs},
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #28
0
def index_view(request, page_app):
    if page_app.type != "":
        organizations = Organization.objects.filter(category__label=page_app.type)
    else:
        organizations = Organization.objects.all()
            
    base_url = u'%s' % (page_app.get_absolute_url())
    
    direct_link = False
    if page_app.type == settings.COOP_PARTENAIRE_LABEL:
        direct_link = True
    
    try:
        search_form = settings.COOP_MEMBER_SEARCH_FORM
    except:
        search_form = False

    center_map = settings.COOP_MAP_DEFAULT_CENTER
        
    if request.method == 'POST': # If the form has been submitted
        # TODO: other filters
        form = PageApp_MembersForm(request.POST)
        if form.is_valid():
            if form.cleaned_data['free_search']:
                organizations = organizations.filter(Q(title__contains=form.cleaned_data['free_search']) | Q(description__contains=form.cleaned_data['free_search']))

            if form.cleaned_data['location']:
                coords = form.cleaned_data['location'].split(",")
                center = geos.Point(float(coords[0]), float(coords[1]))
                radius = form.cleaned_data['location_buffer']
                zone = center.buffer(float(radius))
                
                 # Get the possible location in the buffer...
                possible_locations = Location.objects.filter(point__intersects=zone)
                for o in Location.objects.all():
                    print o.point
                print possible_locations
                print zone
                # ...and filter organization according to these locations
                organizations = organizations.filter(Q(located__location__in=possible_locations))
            
            #if form.cleaned_data['type_exchange']:
            #    organizations = organizations.filter(Q(eway__in=form.cleaned_data['type_exchange']))

            #if form.cleaned_data['type']:
            #    organizations = organizations.filter(Q(etype__in=form.cleaned_data['type']))

    else:
        form = PageApp_MembersForm(initial={'location_buffer': '10'}) # An empty form
    
    rdict = {'object': page_app, 'members': organizations, 'media_path': settings.MEDIA_URL, 'base_url': base_url, 'direct_link': direct_link, 'search_form': search_form, 'form' : form, 'center': center_map}
    
    return render_view('page_members/index.html',
                       rdict,
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #29
0
ファイル: views.py プロジェクト: geonux/coop-mes
def organizations_view(request, page_app):

    #organizations = Organization.objects.filter(engagement__org_admin=True, engagement__person__user=request.user)
    organizations = Organization.objects.filter(engagement__person__user=request.user)
    print organizations

    return render_view('page_account/organizations.html',
        {'organizations': organizations},
        MEDIAS,
        context_instance=RequestContext(request))
コード例 #30
0
def index_view(request, plugin):
    
    if plugin.type != "":
        organizations = Organization.objects.filter(category__label=plugin.type)
    else:
        organizations = Organization.objects.all()
    
    return render_view('plugin_coop_members_icons/index.html',
                       {'object': plugin, 'members': organizations, 'media_path': settings.MEDIA_URL},
                       MEDIAS,
                       context_instance=RequestContext(request))                       
コード例 #31
0
 def render_to_response(self, context, **response_kwargs):
     assert response_kwargs == {}
     context['titles'] = ORGANIZATION_TITLES[:-1]
     try:
         context['charte'] = Page.objects.get(title='Charte').app.text
     except Page.DoesNotExist:
         context['charte'] = u'<p>La page « Charte » n\'existe pas.</p>'
     return render_view(self.get_template_names(),
                        context,
                        ORGANIZATION_MEDIA,
                        context_instance=RequestContext(self.request))
コード例 #32
0
ファイル: views.py プロジェクト: manlan2/ionyweb
def index_view(request, plugin):

    if plugin.lightbox:
        MEDIAS = RENDER_MEDIAS + LIGHTBOX_MEDIAS
    else:
        MEDIAS = RENDER_MEDIAS

    return render_view(plugin.get_templates('plugin_image/index.html'), {
        'plugin': plugin,
        'image': plugin.image
    }, MEDIAS)
コード例 #33
0
def organizations_view(request, page_app):

    #organizations = Organization.objects.filter(engagement__org_admin=True, engagement__person__user=request.user)
    organizations = Organization.objects.filter(
        engagement__person__user=request.user)
    print organizations

    return render_view('page_account/organizations.html',
                       {'organizations': organizations},
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #34
0
ファイル: views.py プロジェクト: ionyse/ionyweb
def index_view(request, plugin):

    if plugin.link_enabled:
        medias = RENDER_MEDIAS
    else:
        medias = None

    return render_view(
        plugin.get_templates('plugin_websitetitle/index.html'),
        {'default_title': request.website.title,
         'object': plugin}, medias)
コード例 #35
0
ファイル: views.py プロジェクト: geonux/coop-mes
 def render_to_response(self, context, **response_kwargs):
     assert response_kwargs == {}
     context['titles'] = ORGANIZATION_TITLES[:-1]
     try:
         context['charte'] = Page.objects.get(title='Charte').app.text
     except Page.DoesNotExist:
         context['charte'] = u'<p>La page « Charte » n\'existe pas.</p>'
     return render_view(self.get_template_names(),
         context,
         ORGANIZATION_MEDIA,
         context_instance=RequestContext(self.request))
コード例 #36
0
ファイル: views.py プロジェクト: geonux/coop-mes
def update_view(request, page_app, pk):
    call = get_object_or_404(CallForTenders, pk=pk)
    if not call.organization.engagement_set.filter(org_admin=True, person__user=request.user).exists():
        return HttpResponseForbidden('Opération interdite')
    form = CallForm(request.POST or None, instance=call)
    if form.is_valid():
        form.save()
        return HttpResponseRedirect('/mon-compte/p/mes-appels-doffres/')
    return render_view('page_calls/edit.html',
                       {'object': page_app, 'form': form},
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #37
0
ファイル: views.py プロジェクト: makinacorpus/coop-mes
def index_view(request, page_app):
    qd = request.GET.copy()
    form = CallSearch(qd)
    if form.is_valid():
        calls = CallForTenders.geo_objects.filter(
            organization__status=ORGANIZATION_STATUSES.VALIDATED)
        calls = calls.filter(
            Q(title__icontains=form.cleaned_data['q'])
            | Q(areas__label__icontains=form.cleaned_data['q'])
            | Q(activity__path__icontains=form.cleaned_data['q'])
            | Q(organization__title__icontains=form.cleaned_data['q'])
            | Q(organization__acronym__icontains=form.cleaned_data['q']))
        if form.cleaned_data['org_type'] == 'public':
            calls = calls.filter(
                organization__is_customer=True, organization__customer_type=1)
        if form.cleaned_data['org_type'] == 'prive':
            calls = calls.filter(
                organization__is_customer=True, organization__customer_type=2)
        if form.cleaned_data['clause']:
            calls = calls.filter(clauses__contains=form.cleaned_data['clause'])
        if form.cleaned_data['organization']:
            calls = calls.filter(
                organization=form.cleaned_data['organization'])
        sector = form.cleaned_data['sector']
        descendants = sector and sector.get_descendants(include_self=True)
        if descendants:
            calls = calls.filter(activity__in=descendants)
        calls = calls.distinct()
        if form.cleaned_data['period'] == 'archive':
            calls = calls.filter(deadline__lt=now())
        elif form.cleaned_data['period'] != 'tout':
            calls = calls.filter(deadline__gte=now())
    else:
        calls = Organization.objects.none()
    paginator = Paginator(calls, 20)
    page = request.GET.get('page')
    try:
        calls_page = paginator.page(page)
    except PageNotAnInteger:
        calls_page = paginator.page(1)
    except EmptyPage:
        calls_page = paginator.page(paginator.num_pages)
    get_params = request.GET.copy()
    if 'page' in get_params:
        del get_params['page']
    return render_view(
        'page_calls/index.html', {
            'object': page_app,
            'form': form,
            'calls': calls_page,
            'get_params': get_params.urlencode()
        }, (),
        context_instance=RequestContext(request))
コード例 #38
0
ファイル: views.py プロジェクト: manlan2/ionyweb
def index_view(request, plugin):

    if plugin.link_enabled:
        medias = RENDER_MEDIAS
    else:
        medias = None

    return render_view(plugin.get_templates('plugin_websitetitle/index.html'),
                       {
                           'default_title': request.website.title,
                           'object': plugin
                       }, medias)
コード例 #39
0
ファイル: views.py プロジェクト: ionyse/ionyweb
def index_view(request, plugin):
    
    if plugin.lightbox:
        MEDIAS = RENDER_MEDIAS + LIGHTBOX_MEDIAS
    else:
        MEDIAS = RENDER_MEDIAS

    return render_view(
        plugin.get_templates('plugin_image/index.html'),
        {'plugin': plugin,
         'image': plugin.image},
        MEDIAS)
コード例 #40
0
ファイル: views.py プロジェクト: geonux/coop-mes
def offer_update_view(request, page_app, pk):
    offer = get_object_or_404(Offer, pk=pk)
    if not offer.provider.engagement_set.filter(org_admin=True, person__user=request.user).exists():
        return HttpResponseForbidden('Opération interdite')
    form = OfferForm(request.POST or None, instance=offer)
    if form.is_valid():
        form.save()
        return HttpResponseRedirect('/mon-compte/p/mes-offres/')
    return render_view('page_directory/offer_edit.html',
                       {'object': page_app, 'form': form, 'org': offer.provider},
                       OFFER_MEDIA,
                       context_instance=RequestContext(request))
コード例 #41
0
def index_view(request, plugin):
    tab = request.GET.get('tab')
    if tab not in ('appels-doffres', 'fournisseurs', 'acheteurs', 'agenda', 'actualites'):
        tab = 'appels-doffres'
    calls = CallForTenders.objects.filter(en_direct=True, organization__status=ORGANIZATION_STATUSES.VALIDATED, deadline__gt=now()).order_by('deadline')[:plugin.max_item]
    providers = Organization.objects.filter(is_provider=True, en_direct=True, status=ORGANIZATION_STATUSES.VALIDATED).order_by('-validation')[:plugin.max_item]
    customers = Organization.objects.filter(is_customer=True, en_direct=True, status=ORGANIZATION_STATUSES.VALIDATED).order_by('-validation')[:plugin.max_item]
    actus = Entry.objects.filter(status=Entry.STATUS_ONLINE).order_by('-publication_date')[:plugin.max_item]
    return render_view('plugin_direct/index.html',
                       {'object': plugin, 'providers': providers, 'customers': customers, 'actus': actus, 'calls': calls, 'tab': tab},
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #42
0
ファイル: views.py プロジェクト: makinacorpus/coop-mes
def index_view(request, page_app):
    qd = request.GET.copy()
    form = CallSearch(qd)
    if form.is_valid():
        calls = CallForTenders.geo_objects.filter(
            organization__status=ORGANIZATION_STATUSES.VALIDATED)
        calls = calls.filter(
            Q(title__icontains=form.cleaned_data['q'])
            | Q(areas__label__icontains=form.cleaned_data['q'])
            | Q(activity__path__icontains=form.cleaned_data['q'])
            | Q(organization__title__icontains=form.cleaned_data['q'])
            | Q(organization__acronym__icontains=form.cleaned_data['q']))
        if form.cleaned_data['org_type'] == 'public':
            calls = calls.filter(organization__is_customer=True,
                                 organization__customer_type=1)
        if form.cleaned_data['org_type'] == 'prive':
            calls = calls.filter(organization__is_customer=True,
                                 organization__customer_type=2)
        if form.cleaned_data['clause']:
            calls = calls.filter(clauses__contains=form.cleaned_data['clause'])
        if form.cleaned_data['organization']:
            calls = calls.filter(
                organization=form.cleaned_data['organization'])
        sector = form.cleaned_data['sector']
        descendants = sector and sector.get_descendants(include_self=True)
        if descendants:
            calls = calls.filter(activity__in=descendants)
        calls = calls.distinct()
        if form.cleaned_data['period'] == 'archive':
            calls = calls.filter(deadline__lt=now())
        elif form.cleaned_data['period'] != 'tout':
            calls = calls.filter(deadline__gte=now())
    else:
        calls = Organization.objects.none()
    paginator = Paginator(calls, 20)
    page = request.GET.get('page')
    try:
        calls_page = paginator.page(page)
    except PageNotAnInteger:
        calls_page = paginator.page(1)
    except EmptyPage:
        calls_page = paginator.page(paginator.num_pages)
    get_params = request.GET.copy()
    if 'page' in get_params:
        del get_params['page']
    return render_view('page_calls/index.html', {
        'object': page_app,
        'form': form,
        'calls': calls_page,
        'get_params': get_params.urlencode()
    }, (),
                       context_instance=RequestContext(request))
コード例 #43
0
def detail_view(request, page_app, pk):
    org = get_object_or_404(Organization,
                            pk=pk,
                            status=ORGANIZATION_STATUSES.VALIDATED)
    calls = org.callfortenders_set.filter(
        deadline__gte=now()).order_by('deadline')
    get_params = request.GET.copy()
    return render_view('page_directory/detail.html', {
        'object': page_app,
        'org': org,
        'calls': calls,
        'get_params': get_params.urlencode()
    }, (),
                       context_instance=RequestContext(request))
コード例 #44
0
ファイル: views.py プロジェクト: geonux/coop-mes
def add_view(request, page_app):
    org = Organization.mine(request)
    if org is None:
        return HttpResponseForbidden('Opération interdite')
    form = CallForm(request.POST or None)
    if form.is_valid():
        call = form.save(commit=False)
        call.organization = org
        call.save()
        return HttpResponseRedirect('/mon-compte/p/mes-appels-doffres/')
    return render_view('page_calls/edit.html',
                       {'object': page_app, 'form': form},
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #45
0
ファイル: views.py プロジェクト: geonux/coop-mes
def offer_add_view(request, page_app):
    org = Organization.mine(request)
    if org is None:
        return HttpResponseForbidden('Opération interdite')
    form = OfferForm(request.POST or None)
    if form.is_valid():
        offer = form.save(commit=False)
        offer.provider = org
        offer.save()
        form.save_m2m()
        return HttpResponseRedirect('/mon-compte/p/mes-offres/')
    return render_view('page_directory/offer_edit.html',
                       {'object': page_app, 'form': form, 'org': org, 'propose': 'propose' in request.GET},
                       OFFER_MEDIA,
                       context_instance=RequestContext(request))
コード例 #46
0
ファイル: views.py プロジェクト: makinacorpus/coop-mes
def update_view(request, page_app, pk):
    call = get_object_or_404(CallForTenders, pk=pk)
    if not call.organization.engagement_set.filter(
            org_admin=True, person__user=request.user).exists():
        return HttpResponseForbidden('Opération interdite')
    form = CallForm(request.POST or None, instance=call)
    if form.is_valid():
        form.save()
        return HttpResponseRedirect('/mon-compte/p/mes-appels-doffres/')
    return render_view('page_calls/edit.html', {
        'object': page_app,
        'form': form
    },
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #47
0
def offer_update_view(request, page_app, pk):
    offer = get_object_or_404(Offer, pk=pk)
    if not offer.provider.engagement_set.filter(
            org_admin=True, person__user=request.user).exists():
        return HttpResponseForbidden('Opération interdite')
    form = OfferForm(request.POST or None, instance=offer)
    if form.is_valid():
        form.save()
        return HttpResponseRedirect('/mon-compte/p/mes-offres/')
    return render_view('page_directory/offer_edit.html', {
        'object': page_app,
        'form': form,
        'org': offer.provider
    },
                       OFFER_MEDIA,
                       context_instance=RequestContext(request))
コード例 #48
0
ファイル: views.py プロジェクト: makinacorpus/coop-mes
def add_view(request, page_app):
    org = Organization.mine(request)
    if org is None:
        return HttpResponseForbidden('Opération interdite')
    form = CallForm(request.POST or None)
    if form.is_valid():
        call = form.save(commit=False)
        call.organization = org
        call.save()
        return HttpResponseRedirect('/mon-compte/p/mes-appels-doffres/')
    return render_view('page_calls/edit.html', {
        'object': page_app,
        'form': form
    },
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #49
0
def offer_add_view(request, page_app):
    org = Organization.mine(request)
    if org is None:
        return HttpResponseForbidden('Opération interdite')
    form = OfferForm(request.POST or None)
    if form.is_valid():
        offer = form.save(commit=False)
        offer.provider = org
        offer.save()
        form.save_m2m()
        return HttpResponseRedirect('/mon-compte/p/mes-offres/')
    return render_view('page_directory/offer_edit.html', {
        'object': page_app,
        'form': form,
        'org': org,
        'propose': 'propose' in request.GET
    },
                       OFFER_MEDIA,
                       context_instance=RequestContext(request))
コード例 #50
0
def login(request,
          template_name='page_account/login.html',
          redirect_field_name=REDIRECT_FIELD_NAME,
          authentication_form=AuthenticationForm):
    """
    Displays the login form and handles the login action.
    """
    redirect_to = request.REQUEST.get(redirect_field_name, '')

    if request.method == "POST":
        form = authentication_form(data=request.POST)
        if form.is_valid():

            # Ensure the user-originating redirection url is safe.
            if not is_safe_url(url=redirect_to, host=request.get_host()):
                redirect_to = '/'

            # Okay, security check complete. Log the user in.
            auth_login(request, form.get_user())

            if request.session.test_cookie_worked():
                request.session.delete_test_cookie()

            return HttpResponseRedirect(redirect_to)
    else:
        form = authentication_form(request)

    request.session.set_test_cookie()

    current_site = get_current_site(request)

    context = {
        'form': form,
        redirect_field_name: redirect_to,
        'site': current_site,
        'site_name': current_site.name,
    }
    return render_view(template_name,
                       context,
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #51
0
ファイル: views.py プロジェクト: tominardi/ionyweb
def index_view(request, plugin):
	
    contact_form = Plugin_ContactForm()
    message = None

    if request.method == "POST" and not request.is_admin_url:
        # Check if we submit this form.
        if int(request.POST['contactform']) == plugin.pk:
            contact_form = Plugin_ContactForm(request.POST)
            if contact_form.is_valid():
                contact_form.send(plugin.emails, default_subject=plugin.subject)
                message = _(u'Message sent')
                contact_form = Plugin_ContactForm()
            else:
                message = _(u'The mail could not be sent')

    return render_view(
        plugin.get_templates('plugin_contact/index.html'),
        {'object': plugin,
         'form': contact_form,
         'message': message})
コード例 #52
0
ファイル: views.py プロジェクト: manlan2/ionyweb
def index_view(request, plugin):
	
    contact_form = Plugin_ContactForm()
    message = None

    if request.method == "POST" and not request.is_admin_url:
        # Check if we submit this form.
        if int(request.POST['contactform']) == plugin.pk:
            contact_form = Plugin_ContactForm(request.POST)
            if contact_form.is_valid():
                contact_form.send(plugin.emails, default_subject=plugin.subject)
                message = _(u'Message sent')
                contact_form = Plugin_ContactForm()
            else:
                message = _(u'The mail could not be sent')

    return render_view(
        plugin.get_templates('plugin_contact/index.html'),
        {'object': plugin,
         'form': contact_form,
         'message': message},
        RENDER_MEDIAS)
コード例 #53
0
def index_view(request, obj):
    "Render the html code in string"
    return render_view('page_text/index.html', {'text': obj.text})
コード例 #54
0
def index_view(request, page_app):
    return render_view('page_sitemap/index.html')
コード例 #55
0
def index_view(request, page_app):
    return render_view('page_account/index.html', {'object': page_app},
                       MEDIAS,
                       context_instance=RequestContext(request))
コード例 #56
0
ファイル: views.py プロジェクト: makinacorpus/coop-mes
def index_view(request, page_app):
    if request.GET.get('display') == 'Annuaire':
        return HttpResponseRedirect('../annuaire/?' + request.GET.urlencode())
    qd = request.GET.copy()
    if not qd.get('area_0') and 'area_1' in qd:
        del qd['area_1']
    if 'dep' in qd:
        try:
            area = Area.objects.get(reference=qd['dep'],
                                    area_type__txt_idx='DEP')
        except Area.DoesNotExist:
            pass
        else:
            qd['area_0'] = area.label
            qd['area_1'] = area.pk
    form = OrgSearch(qd)
    if form.is_valid():
        orgs = Organization.geo_objects.filter(
            status=ORGANIZATION_STATUSES.VALIDATED)
        orgs = orgs.filter(
            Q(title__icontains=form.cleaned_data['q'])
            | Q(acronym__icontains=form.cleaned_data['q'])
            | Q(tagged_items__tag__name__icontains=form.cleaned_data['q'])
            | Q(located__location__city__icontains=form.cleaned_data['q'])
            | Q(activities__path__icontains=form.cleaned_data['q'])
            | Q(offer__activity__path__icontains=form.cleaned_data['q']))
        if form.cleaned_data['org_type'] == 'fournisseur':
            orgs = orgs.filter(is_provider=True)
            if form.cleaned_data['prov_type']:
                orgs = orgs.filter(
                    agreement_iae=form.cleaned_data['prov_type'])
        if form.cleaned_data['org_type'] == 'acheteur-public':
            orgs = orgs.filter(is_customer=True, customer_type=1)
        if form.cleaned_data['org_type'] == 'acheteur-prive':
            orgs = orgs.filter(is_customer=True, customer_type=2)
        interim = form.cleaned_data['interim']
        if interim:
            orgs = orgs.filter(
                offer__activity__label__in=(u'mise à disposition de personnel',
                                            u'travail temporaire'))
        sector = form.cleaned_data['sector']
        descendants = sector and sector.get_descendants(include_self=True)
        if descendants:
            orgs = orgs.filter(offer__activity__in=descendants)
        area = form.cleaned_data.get('area')
        if area:
            try:
                radius = int(form.cleaned_data.get('radius'))
            except:
                radius = 0
            if radius != 0:
                degrees = radius * 360 / 40000
                q = Q(located__location__point__dwithin=(area.polygon,
                                                         degrees))
                q |= Q(offer__area__polygon__dwithin=(area.polygon, degrees))
                orgs = orgs.filter(q)
            else:
                q = Q(located__location__point__contained=area.polygon)
                q |= Q(offer__area__polygon__intersects=area.polygon)
                orgs = orgs.filter(
                    offer__area__polygon__intersects=area.polygon)
        orgs = orgs.distinct()
    else:
        area = None
        orgs = Organization.objects.none()
    get_params = request.GET.copy()
    if area is None:
        bounds = Area.objects.filter(label=settings.REGION_LABEL).extent()
    else:
        bounds = area.polygon.extent
    return render_view('page_map/index.html', {
        'object': page_app,
        'form': form,
        'orgs': orgs,
        'area': area,
        'bounds': bounds,
        'get_params': get_params.urlencode()
    },
                       MEDIAS,
                       context_instance=RequestContext(request))