-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from diverso-lab/refactoring
Refactoring
- Loading branch information
Showing
44 changed files
with
301 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.11-alpine | ||
|
||
# Set the working directory in the container to /app | ||
# Instala el cliente de MySQL para poder usarlo en el script de espera | ||
RUN apk add --no-cache mysql-client | ||
|
||
# Establece el directorio de trabajo en el contenedor en /app | ||
WORKDIR /app | ||
|
||
# Copy the contents of the local app/ directory to the /app directory in the container | ||
# Copia el contenido del directorio local app/ al directorio /app en el contenedor | ||
COPY app/ ./app | ||
|
||
# Copy requirements.txt at the /app working directory | ||
# Copia requirements.txt en el directorio de trabajo /app | ||
COPY requirements.txt . | ||
|
||
# Install any needed packages specified in requirements.txt | ||
# Copia el script wait-for-db.sh y establece los permisos de ejecución | ||
COPY --chmod=+x scripts/wait-for-db.sh ./scripts/ | ||
|
||
# Instala los paquetes necesarios especificados en requirements.txt | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Update pip | ||
# Actualiza pip | ||
RUN pip install --no-cache-dir --upgrade pip | ||
|
||
# Expose port 5000 | ||
# Expone el puerto 5000 | ||
EXPOSE 5000 | ||
|
||
# Run the application | ||
CMD flask db upgrade && flask run --host=0.0.0.0 --port=5000 --reload --debug | ||
|
||
# Ajusta el comando CMD para ejecutar correctamente el script wait-for-db.sh | ||
CMD sh ./scripts/wait-for-db.sh && flask db upgrade && flask run --host=0.0.0.0 --port=5000 --reload --debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,3 @@ | |
|
||
auth_bp = Blueprint('auth', __name__, template_folder='templates') | ||
|
||
from . import routes |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
from flask import Blueprint | ||
|
||
dataset_bp = Blueprint('dataset', __name__, template_folder='templates') | ||
|
||
from . import routes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
from flask import Blueprint | ||
|
||
explore_bp = Blueprint('explore', __name__, template_folder='templates') | ||
|
||
from . import routes |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
from flask import Blueprint | ||
|
||
profile_bp = Blueprint('profile', __name__, template_folder='templates') | ||
|
||
from . import routes |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from app.blueprints.profile.models import UserProfile | ||
from app.repositories.BaseRepository import BaseRepository | ||
|
||
|
||
class UserProfileRepository(BaseRepository): | ||
def __init__(self): | ||
super().__init__(UserProfile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from flask import request, render_template, flash, redirect, url_for, current_app | ||
from flask_login import login_required | ||
|
||
from app.blueprints.profile import profile_bp | ||
from app.blueprints.profile.forms import UserProfileForm | ||
|
||
from app import get_authenticated_user_profile | ||
from app.blueprints.profile.services import UserProfileService | ||
|
||
|
||
@profile_bp.route('/profile/edit', methods=['GET', 'POST']) | ||
@login_required | ||
def edit_profile(): | ||
form = UserProfileForm() | ||
if request.method == 'POST': | ||
|
||
service = UserProfileService() | ||
result, errors = service.update_profile(get_authenticated_user_profile().id, form) | ||
return service.handle_service_response(result, errors, 'profile.edit_profile', 'Profile updated successfully', | ||
'profile/edit.html', form) | ||
|
||
return render_template('profile/edit.html', form=form) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from app.blueprints.profile.repositories import UserProfileRepository | ||
from app.services.BaseService import BaseService | ||
|
||
from flask import current_app | ||
|
||
|
||
class UserProfileService(BaseService): | ||
def __init__(self): | ||
super().__init__(UserProfileRepository()) | ||
|
||
def update_profile(self, user_profile_id, form): | ||
if form.validate(): | ||
updated_instance = self.update(user_profile_id, **form.data) | ||
return updated_instance, None | ||
else: | ||
return None, form.errors |
Oops, something went wrong.