Skip to content

Instantly share code, notes, and snippets.

Avatar

Carolina Soares MariaCarolinass

View GitHub Profile
@MariaCarolinass
MariaCarolinass / models.py
Created Feb 19, 2021
Ordernar os usuários pela quantidade de postagens que ele cadastrou
View models.py
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
nickname = db.Column(db.String(200), unique=True)
posts = db.relationship('Post', backref='author', lazy='dynamic')
def __repr__(self):
return '{}'.format(self.nickname)
View form.py
#!/usr/bin/env python -*- coding: utf-8 -*-
from flask import request
from flask_wtf import FlaskForm, RecaptchaField
from wtforms import StringField, SelectField, TextField, TextAreaField, \
DateField, PasswordField, RadioField, BooleanField, SubmitField
from wtforms.validators import ValidationError, DataRequired, Length, \
Email, EqualTo, Regexp
from app.util.validators import Unique
from datetime import datetime
from flask_babel import _, lazy_gettext as _l
View _source.html
<table>
<tr valign="top">
<td>
<h4><a href="{{ url_for('main.source_profile', title=source.title) }}"
id="color-red">{{ source.title }}</a></h4><br>
<p>{{_('Palavras-Chaves')}}: {{ source.tag }}</p>
</td>
</tr>
</table>
View edit_source.html
{% extends "base.html" %}
{% import 'bootstrap/wtf.html' as wtf %}
{% block app_content %}
<h1 class="text-center">{{_('Editar Fonte') }}</h1><br><br><br>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
{{ wtf.quick_form(form) }}
</div>
<div class="col-md-3"></div>
View _source.html
<table>
<tr valign="top">
<td>
<h4><a href="{{ url_for('main.source_profile', title=source.title) }}" {{ source.title }} </a></h4><br>
<input type="text" value="Amsterdam,Washington,Sydney,Beijing,Cairo" data-role="tagsinput">
</td>
</tr>
</table>
View form.py
class SourceForm(FlaskForm):
title = StringField(_l('Título: *'), validators=[DataRequired(),
Length(min=3)], render_kw={"placeholder": "Digite o título da Fonte de Dados Abertos"})
tag = StringField(_l('Palavras-Chaves: *'), validators=[DataRequired()],
render_kw={"placeholder": "Digite as palavras-chaves da fonte"})
category = SelectField(_l('Categoria: *'), validators=[DataRequired()],
choices=[('Corona Vírus','Corona Vírus'), ('Saúde', 'Saúde'), ('Educação', 'Educação'),
('Cinema', 'Cinema'), ('Música', 'Música'), ('Tecnologia', 'Tecnologia'), ('Ciência', 'Ciência'),
('Segurança Pública', 'Segurança Pública'), ('Meio Ambiente', 'Meio Ambiente'), ('Cultura', 'Cultura'),
('Países', 'Países'), ('IBGE', 'IBGE'), ('Clima', 'Clima'), ('Lazer', 'Lazer')], default=1)
View _post.html
<p>Categoria: <a href="category/{{ remove_accents(post.category) }}">{{ post.category }}</a></p>
View index.html
<h2>{{ _('Encontre as principais categorias em Fontes de Dados Abertos e Aplicações') }}</h2><br><br><br>
<div class="row"><div class="col-md-4">
<h4><a class="topic-grid-item js-topic-grid-item" href="{{ url_for('category.CoronaVirus') }}" id="category-link">Corona Vírus</a></h4>
<h4><a class="topic-grid-item js-topic-grid-item" href="{{ url_for('category.Saude') }}" id="category-link">Saúde</a></h4>
<h4><a class="topic-grid-item js-topic-grid-item" href="{{ url_for('category.Educacao') }}" id="category-link">Educação</a></h4>
</div><div class="col-md-4">
<h4><a class="topic-grid-item js-topic-grid-item" href="{{ url_for('category.Cinema') }}" id="category-link">Cinema</a></h4>
<h4><a class="topic-grid-item js-topic-grid-item" href="{{ url_for('category.Musica') }}" id="category-link">Música</a></h4>
<h4><a class="topic-grid-item js-topic-grid-item" href="{{ url_for('category.Tecnologia') }}" id="category-link">Tecnologia</a></h4>
</div><div class="col-md-4">
View base.html
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="{{ url_for('main.index') }}">{{ _('Página Inicial') }}</a></li>
<li><a href="{{ url_for('main.explore') }}">{{ _('Explorar') }}</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
{% if current_user.is_anonymous %}
<li><a href="{{ url_for('auth.login') }}">{{ _('Entrar') }}</a></li>
<li><a href="{{ url_for('auth.register') }}">{{ _('Inscrever-se') }}</a></li>
{% else %}
@MariaCarolinass
MariaCarolinass / _similar.html
Last active Jul 17, 2020
Exibir dados do campo de form autocomplete
View _similar.html
<table>
<tr valign="top">
<td>
<h4>{{ similar.name }}</h4><br>
</td>
</tr>
</table>