Ejemplo n.º 1
0
def _render_vote(vote, count):
    if vote:
        if vote.position == 'pour':
            return L.small(".badge.badge-success") / vote.position
        elif vote.position == 'contre':
            return L.small(".badge.badge-danger") / vote.position
        elif vote.position == 'abstention':
            return L.small(".badge.badge-warning") / vote.position
    else:
        return L.small(".badge.badge-info") / f"absent(e) sur {count}"
def _ext(ext):
    return L.div / (
        L.small('.extlink') / (
            L.a(href='/ext/%s.html' % ext['ext_id']) /
                ('#' + ext['ext_id'])
        ),
        L.h2(id=ext['ext_id']) /
            (L.a(href=ext['url'] if ext['url'] else '') / ext['name']),
        L.small / _add_commas(ext['user_count']),
        L.ul / ((
            L.li / (
                L.a(href=file['storage_url']) / (
                    file['name'].replace('.zip', ''),
                    ' - ',
                    L.small / (' ' + _sizeof_fmt(file['size'])),
                ),
                ' ',
                L.small / (
                    L.a(target='_blank', rel='noreferrer',
                            href=VIEW_SOURCE_URL + file['storage_url']) /
                        'view source'
                ),
            )
        ) for file in ext['files'])
    )
Ejemplo n.º 3
0
def homepage(request):
    deputes = Depute.objects.filter(actif=True).order_by(
        Lower('nom'), 'prenom')
    return HttpResponse(
        template([
            raw("""
		<div class="alert alert-dismissible alert-info">
		  <p>Ce site permet de retrouver facilement les votes de vos députés</p>
		  <p>Vous pouvez trouver votre député par circonscription sur
		  	 <a href="https://www.nosdeputes.fr/circonscription" class="alert-link">NosDéputés.fr</a></p>
		</div>
		"""),
            L.p / L.a(href="/deputes/inactifs") /
            L.button(".btn.btn-warning") / "voir députés inactifs",
            L.h2 / ["Députés ", L.small(".text-muted") / " actifs"],
            L.div(".list-group") / [
                L.
                a(".list-group-item.list-group-item-action.flex-column.align-items-start",
                  href=dep.url()) / [
                      L.div(".d-flex.w-100.justify-content-between") / [
                          L.h5(".mb-1") / f"{dep.nom}, {dep.prenom}",
                          L.small / f"{dep.groupe}"
                      ]
                  ] for dep in deputes
            ],
        ]))
Ejemplo n.º 4
0
def depute(request, dep_id):
    dep = Depute.objects.get(identifiant=dep_id)
    dossiers = Dossier.objects.filter(
        date_promulgation__isnull=False).order_by("-date_promulgation",
                                                  "titre")
    return HttpResponse(
        template([
            _render_breadcrumb([dep]), L.p / (
                L.a(href=dep.url() + "/lois-en-cours") /
                L.button(".btn.btn-warning") / "voir lois en cours",
                ' ',
                L.a(href=dep.url() + "/autres-votes") /
                L.button(".btn.btn-warning") / "voir autres votes",
            ), L.h2 / ["Lois", L.small(".text-muted") / " promulguées"],
            L.div(".list-group") / [
                L.
                a(".list-group-item.list-group-item-action.flex-column.align-items-start",
                  href=dos.url(dep)) / [
                      L.div(".d-flex.w-100.justify-content-between") / [
                          L.h5(".mb-1") / dos.titre,
                          _display_depute_vote(dos, dep),
                      ]
                  ] for dos in dossiers
            ]
        ]))
def _ext(ext):
    return L.div / (
        L.small('.extlink') / (
            L.a(href='/ext/%s.html' % ext['ext_id']) /
                ('#' + ext['ext_id'])
        ),
        L.h2(id=ext['ext_id']) /
            (L.a(href=ext['url'] if ext['url'] else '') / ext['name']),
        L.small / _add_commas(ext['user_count']),
        L.ul / ((
            L.li / (
                L.a(href=file['storage_url']) / (
                    file['name'].replace('.zip', ''),
                    ' - ',
                    L.small / (' ' + _sizeof_fmt(file['size'])),
                    ' - ',
                    L.small / (file['created']),
                ),
                ' ',
                L.small / (
                    L.a(target='_blank', rel='noreferrer',
                            href=VIEW_SOURCE_URL + file['storage_url']) /
                        'view source'
                ),
            )
        ) for file in ext['files'])
    )
Ejemplo n.º 6
0
def deputes_inactifs(request):
    deputes_inactifs = Depute.objects.filter(actif=False).order_by(
        Lower('nom'), 'prenom')
    return HttpResponse(
        template([
            L.h2 /
            ["Députés ", L.small(".text-muted") / " inactifs"],
            L.div(".list-group") / [
                L.
                a(".list-group-item.list-group-item-action.flex-column.align-items-start",
                  href=dep.url()) / [
                      L.div(".d-flex.w-100.justify-content-between") / [
                          L.h5(".mb-1") / f"{dep.nom}, {dep.prenom}",
                          L.small / f"{dep.groupe}"
                      ]
                  ] for dep in deputes_inactifs
            ]
        ]))
Ejemplo n.º 7
0
def lois_en_cours(request, dep_id):
    dep = Depute.objects.get(identifiant=dep_id)
    dossiers = Dossier.objects.filter(date_promulgation__isnull=True)
    return HttpResponse(
        template([
            _render_breadcrumb([dep, 'Lois en cours']), L.h2 /
            ["Lois", L.small(".text-muted") / " en cours d'étude"],
            L.div(".list-group") / [
                L.
                a(".list-group-item.list-group-item-action.flex-column.align-items-start",
                  href=dos.url(dep)) / [
                      L.div(".d-flex.w-100.justify-content-between") / [
                          L.h5(".mb-1") / dos.titre,
                          _display_depute_vote(dos, dep),
                      ]
                  ] for dos in dossiers
            ]
        ]))
Ejemplo n.º 8
0
def depute_etape(request, dep_id, etape_id):
    dep = Depute.objects.get(identifiant=dep_id)
    etape = Etape.objects.get(identifiant=etape_id)
    dos = etape.dossier
    try:
        scrutin = etape.scrutin_set.filter(dossier__isnull=True,
                                           article__isnull=True).first()
    except:
        scrutin = None
    articles = etape.scrutin_set.values_list(
        'article', flat=True).order_by('article').distinct()
    articles = [a for a in articles if a]
    articles.sort(key=_sort_articles)

    scrutins_amendements = etape.scrutin_set.filter(dossier=dos, etape=etape)

    return HttpResponse(
        template([
            _render_breadcrumb([dep, dos, etape]),
            (L.span('.badge.badge-info') / (
                'Le ',
                scrutin.date,
                (' ', scrutin.heure) if scrutin.heure else None,
            ), ) if scrutin else None,
            L.p / ((
                ' ',
                L.a(href=scrutin.url_an) / L.button(".btn.btn-info") /
                f'Scrutin',
                (
                    ' ',
                    L.a(href=scrutin.url_video) / L.button(".btn.btn-info") /
                    "video du  vote",
                ) if scrutin.url_video else None,
                (
                    ' ',
                    L.a(href=scrutin.url_CR) / L.button(".btn.btn-info") /
                    "compte-rendu",
                ) if scrutin.url_CR else None,
            ) if scrutin else None),
            (L.h2 / ["Articles", L.small(".text-muted") / " votés"],
             L.div(".list-group") / [
                 L.
                 a(".list-group-item.list-group-item-action.flex-column.align-items-start",
                   href="/" + dep.identifiant + "/etape/" + etape.identifiant +
                   "/article/" + article) / [
                       L.div(".d-flex.w-100.justify-content-between") / [
                           L.h5(".mb-1") / f"Article {article}",
                           _display_article_vote(etape, dep, article),
                       ]
                   ] for article in articles
             ]) if articles else None,
            (L.br, L.br, L.h2 / [
                "Amendements et motions",
                L.small(".text-muted") / " votés"
            ], L.div(".list-group") / [
                L.
                a(".list-group-item.list-group-item-action.flex-column.align-items-start",
                  href="/" + dep.identifiant + "/scrutin/" +
                  str(amdt_scrutin.id)) / [
                      L.div(".d-flex.w-100.justify-content-between") / [
                          L.h5(".mb-1") / f"{amdt_scrutin.objet}",
                          _display_scrutin_vote(dep, amdt_scrutin),
                      ]
                  ] for amdt_scrutin in scrutins_amendements
            ]) if scrutins_amendements.count() else None,
        ]))