Пример #1
0
def former_mps(request):
    former_members = ElectedMember.objects.exclude(end_date__isnull=True)\
        .order_by('riding__province', 'politician__name_family', '-start_date')\
        .select_related('politician', 'riding', 'party')
    seen = set()
    object_list = []
    for member in former_members:
        if member.politician_id not in seen:
            object_list.append(member)
            seen.add(member.politician_id)
    
    c = RequestContext(request, {
        'object_list': object_list,
        'title': 'Former MPs (since 1994)'
    })
    t = loader.get_template("politicians/former_electedmember_list.html")
    return HttpResponse(t.render(c))
Пример #2
0
def tag_detail(request,tag):

    try:
        tag = Tag.objects.get(name=tag)
    except:
        raise Http404

    tagged_items = tag.items.all()
    object_list = []

    for item in tagged_items:
        object_list.append(item.object)

    return render_to_response('tagging/tag_detail.html',
                              {'tag_name': tag,
                               'object_list': object_list},
                              context_instance = RequestContext(request))
Пример #3
0
def former_mps(request):
    former_members = (
        ElectedMember.objects.all()
        .order_by("riding__province", "politician__name_family", "-start_date")
        .select_related("politician", "riding", "party")
    )
    seen = set()
    object_list = []
    for member in former_members:
        if member.politician.id not in seen:
            if member.end_date:
                # Not a current MP
                object_list.append(member)
            seen.add(member.politician.id)

    c = RequestContext(request, {"object_list": object_list, "title": "Former MPs (since 1994)"})
    t = loader.get_template("politicians/former_electedmember_list.html")
    return HttpResponse(t.render(c))
Пример #4
0
def xml_plugins(request):
    """
    The XML file

    accepted parameters:

        * qgis: qgis version
        * stable_only: 0/1
        * package_name: Plugin.package_name

    """
    qg_version = vjust(request.GET.get('qgis', '1.8.0'), fillchar=' ', level=2, force_zero=True)
    stable_only = request.GET.get('stable_only', '0')
    package_name = request.GET.get('package_name', None)

    filters = {}
    version_filters = {}
    object_list = []

    if qg_version:
        filters.update({'pluginversion__min_qg_version__lte' : qg_version})
        version_filters.update({'min_qg_version__lte' : qg_version})
        filters.update({'pluginversion__max_qg_version__gte' : qg_version})
        version_filters.update({'max_qg_version__gte' : qg_version})

    # Get all versions for the given plugin
    if package_name:
        filters.update({'package_name' : package_name})
        try:
            plugin = Plugin.approved_objects.get(**filters)
            plugin_version_filters = copy.copy(version_filters)
            plugin_version_filters.update({'plugin' : plugin})
            for plugin_version in PluginVersion.stable_objects.filter(**plugin_version_filters):
                object_list.append(plugin_version)
            if stable_only != '1':
                for plugin_version in PluginVersion.experimental_objects.filter(**plugin_version_filters):
                    object_list.append(plugin_version)
        except Plugin.DoesNotExist:
            pass
    else:
        for plugin in Plugin.approved_objects.filter(**filters):
            plugin_version_filters = copy.copy(version_filters)
            plugin_version_filters.update({'plugin' : plugin})
            try:
                object_list.append(PluginVersion.stable_objects.filter(**plugin_version_filters)[0])
            except IndexError:
                pass
            if stable_only != '1':
                try:
                    object_list.append(PluginVersion.experimental_objects.filter(**plugin_version_filters)[0])
                except IndexError:
                    pass

    return render_to_response('plugins/plugins.xml', {'object_list': object_list}, mimetype='text/xml', context_instance=RequestContext(request))
Пример #5
0
def former_mps(request):
    former_members = ElectedMember.objects.all()\
        .order_by('riding__province', 'politician__name_family', '-start_date')\
        .select_related('politician', 'riding', 'party')
    seen = set()
    object_list = []
    for member in former_members:
        if member.politician.id not in seen:
            if member.end_date:
                # Not a current MP
                object_list.append(member)
            seen.add(member.politician.id)
    
    c = RequestContext(request, {
        'object_list': object_list,
        'title': 'Former MPs (since 1994)'
    })
    t = loader.get_template("politicians/former_electedmember_list.html")
    return HttpResponse(t.render(c))
Пример #6
0
def xml_plugins(request):
    """
    The XML file

    accepted parameters:

        * qgis: qgis version
        * stable_only: 0/1
    """
    qg_version = vjust(request.GET.get('qgis'))
    stable_only = request.GET.get('stable_only', '0')
    
    filters = {}
    version_filters = {}
    object_list = []
    
    if qg_version:
        filters.update({'pluginversion__min_qg_version__lte' : qg_version})
        version_filters.update({'min_qg_version__lte' : qg_version})
        filters.update({'pluginversion__max_qg_version__gte' : qg_version})
        version_filters.update({'max_qg_version__gte' : qg_version})

    for plugin in Plugin.approved_objects.filter(**filters):
        plugin_version_filters = copy.copy(version_filters)
        plugin_version_filters.update({'plugin' : plugin})
        try:
            object_list.append(PluginVersion.stable_objects.filter(**plugin_version_filters)[0])
        except IndexError:
            pass
        if stable_only != '1':
            try:
                object_list.append(PluginVersion.experimental_objects.filter(**plugin_version_filters)[0])
            except IndexError:
                pass
     
    return render_to_response('plugins/plugins.xml', {'object_list': object_list}, mimetype='text/xml', context_instance=RequestContext(request))