diff --git a/app.py b/app.py index 112bf15..a5820bd 100644 --- a/app.py +++ b/app.py @@ -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 %}

Ooops, parece que nadie te invitó aquí

{% 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/") @@ -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(): diff --git a/static/styles.css b/static/styles.css index 97d5128..047e791 100644 --- a/static/styles.css +++ b/static/styles.css @@ -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%; +} \ No newline at end of file diff --git a/templates/add_pin.html b/templates/add_pin.html index 268fff1..9a06278 100644 --- a/templates/add_pin.html +++ b/templates/add_pin.html @@ -4,8 +4,9 @@ {{ form.description.label }}
{{ form.description(size=32) }}

--> - - {{ form.photo.label }}
+ {{ form.description.label }} + {{ form.description }} + {{ form.photo.label }} {{ form.photo() }} {{ form.typeofpin }} diff --git a/templates/base.html b/templates/base.html index b46ee13..b49eabc 100644 --- a/templates/base.html +++ b/templates/base.html @@ -10,7 +10,7 @@ - + diff --git a/templates/index.html b/templates/index.html index 38e9e06..d18ee66 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3,7 +3,7 @@ {% block content %}