1
0
forked from orson/bachemap

whole bunch of changes

This commit is contained in:
kprftw 2024-09-04 21:22:51 -06:00
parent 96a866d58a
commit 0dd08a5275
7 changed files with 78 additions and 140 deletions

43
app.py
View File

@ -41,7 +41,7 @@ def create_app():
return None
class PinForm(FlaskForm):
description = StringField('Description', validators=[DataRequired()])
description = StringField('¿Qué estamos viendo?', validators=[DataRequired()])
photo = FileField('Evidencia fotogénica', validators=[DataRequired()])
timedate = DateTimeField(default=datetime.now())
typeofpin = SelectField('Tipo de cosa', choices=['bache', 'coladera', 'obra sin terminar', 'escombro', 'robo-asalto', 'biciestacionamiento', 'mala iluminación'])
@ -93,6 +93,7 @@ def create_app():
'lng': request.form['lng'],
'typeofpin': request.form['typeofpin'],
'added_by': current_user.id,
'description': request.form['description']
}
mongo.db.pins.insert_one(pin)
flash('¡Gracias por tu aportación!')
@ -115,7 +116,7 @@ def create_app():
def registrame(referral_code):
inviter = mongo.db.users.find_one({"referral_code": referral_code})
if not inviter:
return "Ooops, parece que nadie te invitó aquí", 404
return "{% extends secondbase.html %} {% block content %} <h1>Ooops, parece que nadie te invitó aquí</h1> {% endblock %}", 406
if request.method == 'POST':
username = request.form['username']
@ -129,7 +130,9 @@ def create_app():
}
new_user_id = mongo.db.users.insert_one(new_user_data).inserted_id
invite_link = url_for('registrame', referral_code=new_user_data['referral_code'], _external=True)
return render_template('dashboard.html', invite_link=invite_link)
login_user(load_user(new_user_id))
return redirect(url_for('index'))
#return render_template('dashboard.html', invite_link=invite_link)
if request.method == 'GET':
return render_template('register.html', form=RegistrationForm())
@ -144,7 +147,7 @@ def create_app():
if user_data and check_password_hash(user_data['pwd'], pwd):
user = User(user_data)
login_user(user)
return redirect(url_for('dashboard'))
return redirect(url_for('index'))
else:
return render_template('login.html', messages = 'Ooops, no hay tal usuario', form=form2)
return render_template('login.html',form=form2)
@ -162,13 +165,20 @@ def create_app():
if not current_user.is_admin:
return redirect(url_for('index'))
else:
user_to_remove = mongo.db.users.find_one({"invited_by": user_id})
user_to_remove = mongo.db.users.find_one({"_id": ObjectId(user_id)})
if not user_to_remove:
return "A este ya me lo desheredaron", 404
else:
# invited_by es un string con el user id, pero para eliminar a un usuario por id, ocupamos el ObjectId(string del user id)
# encontrando todos los usuarios invitados por el traidor para eliminar todos los pines que pusieron
for user in mongo.db.users.find({'invited_by': user_to_remove.id}):
mongo.db.pins.delete_many({"added_by": user.id})
# luego eliminamos a todos los usuarios cuyos pines acabamos de eliminar
mongo.db.users.delete_many({"invited_by": user_id})
#eliminamos los pines del usuario infractor
mongo.db.pins.delete_many({"added_by": user_to_remove.id})
# finalmente, eliminamos al usuario infractor
mongo.db.users.delete_one({"_id": ObjectId(user_id)})
mongo.db.pins.delete_many({"user_id": user_id})
return redirect(url_for('dashboard'))
@app.route("/remove_pin/<pin_id>")
@ -187,15 +197,18 @@ def create_app():
@app.route('/dashboard')
@login_required
def dashboard():
if not current_user.is_authenticated:
return redirect(url_for('thelogin'))
if not current_user.is_admin:
pins = list(mongo.db.pins.find({"added_by": current_user.id}))
return render_template('dashboard.html', pins=pins)
if current_user.is_admin:
users = list(mongo.db.users.find())
pins = list(mongo.db.pins.find())
return render_template('dashboard.html', users=users, pins=pins)
if request.method == 'GET':
if not current_user.is_authenticated:
return redirect(url_for('thelogin'))
if not current_user.is_admin:
pins = list(mongo.db.pins.find({"added_by": current_user.id}))
return render_template('dashboard.html', pins=pins)
if current_user.is_admin:
users = list(mongo.db.users.find())
pins = list(mongo.db.pins.find())
return render_template('dashboard.html', users=users, pins=pins)
#if request.method == 'POST':
# pass
@app.cli.command('add_user')
def add_user():

View File

@ -6,6 +6,10 @@ body, html {
height: 100%;
}
html {
font-size:130%;
}
h1 {
text-align: center;
}
@ -17,6 +21,7 @@ div#pinner-modal form {
border: 1px solid #ccc;
border-radius: 5px;
background-color: rgb(205, 243, 148, 0.7);
font-size: 135%;
}
form p {
@ -28,6 +33,7 @@ form p {
height: 100vh;
margin: 0 0;
position: relative;
font-size: 120%;
}
main {
@ -57,11 +63,11 @@ div.pinner-modal {
div.pinner-modal.active {
bottom: 0;
background-color: rgb(205, 243, 148, 0.7);
background-color: rgba(202, 216, 3, 0.7);
}
div.pinner-modal form {
background-color: rgb(205, 243, 148, 0.7);
background-color: rgba(202, 216, 3, 0.7);
}
nav {
@ -69,10 +75,10 @@ nav {
top:0;
left: 0;
right: 0;
background-color: rgba(205, 243, 148, 0.7);
background-color: rgba(202, 216, 3, 0.7);
padding: 5px;
z-index: 1000;
color:azure;
font-size: 120%;
}
@ -84,110 +90,26 @@ nav {
}
.fa, .far, .fas {
color:rgb(0, 0, 0);
color:black;
text-shadow: -1px 0 rgb(255, 136, 0), 0 1px rgb(255, 136, 0), 1px 0 rgb(255, 136, 0), 0 -1px rgb(255, 136, 0);
font-size: larger;
margin-left: -10px;
margin-top: -10px;
font-size: 2rem;
filter:drop-shadow(0 0 0.2rem orange);
}
path-derping {
fill:orangered;
stroke: orangered;
stroke-width:1px;
stroke-dasharray: 2,2;
stroke-linejoin: round;
}
@media (max-width: 1024px) and (min-width: 768px) {
div#pinner-modal form {
max-width: 80%;
padding: 20px;
}
div.leaflet-popup-content {
width: 80%;
}
div.pinner-modal {
top: 8vh;
left: 5%;
width: 90%;
padding: 1.2rem; /* Slightly larger padding for better touch interaction */
}
nav {
padding: 12px; /* Increased padding for easier interaction */
font-size: 1.2rem; /* Increased font size for readability */
}
i.fa, i.far, i.fas {
font-size: 1.6rem; /* Slightly larger icons for better usability */
margin-left: -10px;
margin-top: -10px;
}
button {
padding: 15px 25px; /* Larger buttons for easier tapping */
font-size: 1.2rem; /* Increase font size for better readability */
border-radius: 8px; /* Rounded corners for a modern look */
}
input[type="text"], input[type="password"], input[type="email"], textarea {
font-size: 1.4rem; /* Ensure input text is readable */
padding: 12px; /* Comfortable padding for touch input */
border-radius: 5px; /* Slight rounding for aesthetic consistency */
}
h1 {
font-size: 2.5rem; /* Larger header text for readability on tablets */
}
}
@media (max-width: 767px) {
div#pinner-modal form {
max-width: 90%;
padding: 15px;
}
div.leaflet-pane div.leaflet-popup div.leaflet-popup-content-wrapper div.leaflet-popup-content {
width: 90%;
font-size: 2rem !important;
}
div.leaflet-popup-content {
background-color: red;
}
div.pinner-modal {
top: 5vh;
left: 5%;
width: 90%;
padding: 1rem; /* Adequate padding for small screens */
}
nav {
padding: 20px; /* Larger padding for tappable navigation */
font-size: 1.4rem !important; /* Increased font size for readability */
}
.fa, .far, .fas {
font-size: 2.2rem !important; /* Larger icons for touch interactions */
margin-left: -10px;
margin-top: -10px;
}
button {
padding: 18px 30px; /* Large buttons for touch interaction */
font-size: 1.6rem !important; /* Increased font size for readability */
border-radius: 10px; /* Rounded corners for modern design */
}
input[type="text"], input[type="password"], input[type="email"], textarea {
font-size: 1.6rem !important; /* Larger input text for readability */
padding: 15px; /* More padding for ease of input */
border-radius: 5px;
}
h1 {
font-size: 3rem; /* Larger header text for small screens */
}
#map {
height: 65vh; /* Reduced height to make space for other elements */
}
}
flashes {
position: relative;
z-index: 1001;
border-radius: 20px;
background-color: rgba(0,150,0,0.8);
top: 8%;
}

View File

@ -4,8 +4,9 @@
{{ form.description.label }}<br>
{{ form.description(size=32) }}
</p>-->
{{ form.photo.label }}<br>
{{ form.description.label }}
{{ form.description }}
{{ form.photo.label }}
{{ form.photo() }}
{{ form.typeofpin }}

View File

@ -10,7 +10,7 @@
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
crossorigin=""></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>

View File

@ -3,7 +3,7 @@
{% block content %}
<div id="map" style="height: 100%; border-style: groove; border-radius: 22px; border-width: 4px; position: absolute;"></div>
<script>
var map = new L.map('map', {zoomControl: false}, center=([20.57, -100.38], zoom=13));
var map = new L.map('map', {zoomControl: false}, center=([20.57, -100.38], zoom=16));
var user_marker = new L.marker([20.57, -100.38]);
var user_radial = new L.circle(L.circle(user_marker.latlng));
@ -11,11 +11,12 @@
var iconTypes = {
'bache': '<i class="fas fa-exclamation-triangle"></i>',
'coladera': '<i class="fas fa-ring"></i>',
'obra sin terminar': '<i class="far fa-wrench"></i>',
'obra sin terminar': '<i class="fas fa-wrench"></i>',
'escombro': '<i class="far fa-trash-alt"></i>',
'robo-asalto': '<i class="far fa-skull"></i>',
'biciestacionamiento': '<i class="far fa-home"></i>',
'mala iluminación': '<i class="far fa-lightbulb"></i>'
'robo-asalto': '<i class="fas fa-skull"></i>',
'biciestacionamiento': '<i class="fas fa-bicycle"></i>',
'mala iluminación': '<i class="far fa-lightbulb"></i>',
};
{% for pin in pins %}
@ -27,7 +28,7 @@
iconAnchor:[5,5],
});
L.marker([{{ pin.lat }}, {{ pin.lng }}], {icon: icon}).addTo(map)
.bindPopup("<b>{{ pin.description }}</b><p>Fecha del reporte: {{pin.time}}</p><br><img src='{{ pin.photo }}'>");
.bindPopup("<b>{{ pin.description }}</b><p>Fecha del reporte: {{pin.time}}</p><br><img src='{{ pin.photo }}'>");
{% endfor %}
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
@ -36,6 +37,7 @@
tileSize: 256,
maxZoom: 19,
maxNativeZoom: 18,
//zoomOffset: 1,
}).addTo(map);
@ -45,6 +47,8 @@
// Add a pin (marker) at the user's location
user_marker = L.marker(e.latlng).addTo(map)
.bindPopup("Te detectamos en un radio de " + radius + " metros de este punto").openPopup();
document.getElementById('lat').value = e.latlng.lat;
document.getElementById('lng').value = e.latlng.lng;
// Add a circle around the user's location
user_radial = L.circle(e.latlng, radius).addTo(map);
// Center the map on the user's location
@ -61,7 +65,7 @@
map.on('locationerror', onLocationError);
// Start the location detection
map.locate({setView: true, maxZoom: 16});
map.locate({setView: true, zoom: 16});
map.on('click', function(e) {
var latlng = e.latlng;
document.getElementById('lat').value = latlng.lat;

View File

@ -2,17 +2,15 @@
{% block content %}
<div style="padding: 50px; overflow-y: scroll;">
<h2>Somos civiles y voluntari@s</h2>
<h4>Estamos cansad@s de lidiar con dos cosas principales</h4>
<p>La mala administración de recursos públicos.</p>
<p>Los "influencers" de tres pesos que se dedican a atacar a quienes tratan de cambiar las cosas para bien.</p>
<h3>Este proyecto es de gente libre para gente libre</h3>
<p>Si ves este mapa y te molesta que alguien se atreva a profanar el nombre de [inserte su partido político favorito aquí], entonces deja de trabajar para quienes no tienen ni un ápice de escrúpulos.</p>
<p>Si quieres participar en este proyecto aportando datos valiosos, consigue que alguien te de una invitación, porque si nadie te invita, no estás invitad@.</p>
<h4>Somos civiles y voluntari@s</h4>
<p>Esta página es un servicio comunitario desarrollado por el hackspace Kernel Panic Room, con un (maravilloso) dominio patrocinado por el programa de RSE de Qro.mx.</p>
<p>Nuestro objetivo es construir un puente entre la ciudadanía y las autoridades estatales y municipales para poder recabar, catalogar y visibilizar los problemas infraestructurales de nuestra entindad, con el fin de facilitar que se solucionen.</p>
<p>No perseguimos fines políticos, sólo estamos interesad@s en mejorar nuestro entorno y la calidad de vida que tenemos.</p>
<h2>Este mapa no hubiera sido posible si no hubieramos conocido a José Luis Ramos</h2>
<p>José Luis falleció en Marzo del 2024. No sólo se nos fue una persona maravillosa, sino también el activista más activo que much@s de nosotr@s conocimos. Este mapa es un homenaje a su vida y a la lucha que encabezó siempre buscando hacer del mundo un lugar mejor para <b>tod@s</b>. Sí, incluso para quienes nunca lo entendieron a él o a su lucha.</p>
<p>Nos volveremos a ver, amigo José Luis, y rodaremos juntos de nuevo. Esperamos que te estés riendo desde las alturas de tu vuelo </p>
<p>Nos volveremos a ver, amigo José Luis, y rodaremos juntos de nuevo. Esperamos que te estés riendo desde las alturas de tu vuelo.</p>
<img src="{{url_for('static', filename='images/ramos.jpg')}}">
</div>

View File

@ -22,7 +22,7 @@
</nav>
{% with messages = get_flashed_messages() %}
{% if messages %}
<div style="position:absolute; z-index: 9999;">
<div style="position:sticky; z-index: 9999;">
<ul class="flashes">
{% for message in messages %}
<li>{{message}}</li>