files-server-fastapi 0.1.7__tar.gz → 0.1.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/PKG-INFO +2 -1
  2. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/pyproject.toml +2 -1
  3. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/files/acls_router.py +11 -6
  4. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/files/constants.py +10 -2
  5. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/files/open_url_router.py +2 -2
  6. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/uv.lock +1 -1
  7. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/.gitignore +0 -0
  8. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/.python-version +0 -0
  9. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/LICENSE +0 -0
  10. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/MANIFEST.in +0 -0
  11. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/README.md +0 -0
  12. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/__init__.py +0 -0
  13. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/files/__init__.py +0 -0
  14. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/files/dependencies.py +0 -0
  15. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/files/download_router.py +0 -0
  16. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/files/folder_router.py +0 -0
  17. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/files/list_router.py +0 -0
  18. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/files/tree_router.py +0 -0
  19. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/files/upload_router.py +0 -0
  20. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/models/__init__.py +0 -0
  21. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/models/area_model.py +0 -0
  22. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/models/permisos_model.py +0 -0
  23. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/models/rol_model.py +0 -0
  24. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/models/rutas_model.py +0 -0
  25. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/models/users_extend_model.py +0 -0
  26. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/routers/__init__.py +0 -0
  27. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/routers/area_router.py +0 -0
  28. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/routers/files_router.py +0 -0
  29. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/routers/permisos_router.py +0 -0
  30. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/routers/rol_router.py +0 -0
  31. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/routers/rutas_router.py +0 -0
  32. {files_server_fastapi-0.1.7 → files_server_fastapi-0.1.8}/src/files_server_fastapi/routers/users_extend_router.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: files-server-fastapi
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary: Este repositorio es un paquete python desarrollado con FastAPI, gestiona la comunicación con un servidor Samba y utiliza PostgreSQL para administrar rutas de archivos y el control de acceso basado en roles (RBAC) de los usuarios.
5
5
  Project-URL: Homepage, https://github.com/AldoBP/files-server-fastapi
6
6
  Project-URL: Repository, https://github.com/AldoBP/files-server-fastapi
@@ -35,6 +35,7 @@ Classifier: Programming Language :: Python :: 3
35
35
  Classifier: Programming Language :: Python :: 3.10
36
36
  Requires-Python: >=3.10
37
37
  Requires-Dist: oauth2fast-fastapi==0.2.5
38
+ Requires-Dist: python-dotenv
38
39
  Description-Content-Type: text/markdown
39
40
 
40
41
  # files-server-fastapi
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "files-server-fastapi"
3
- version = "0.1.7"
3
+ version = "0.1.8"
4
4
  description = "Este repositorio es un paquete python desarrollado con FastAPI, gestiona la comunicación con un servidor Samba y utiliza PostgreSQL para administrar rutas de archivos y el control de acceso basado en roles (RBAC) de los usuarios."
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
@@ -17,6 +17,7 @@ classifiers = [
17
17
  requires-python = ">=3.10"
18
18
  dependencies = [
19
19
  "oauth2fast-fastapi==0.2.5",
20
+ "python-dotenv",
20
21
  ]
21
22
 
22
23
  [dependency-groups]
@@ -9,6 +9,7 @@ from oauth2fast_fastapi import get_current_user, User
9
9
  from files_server_fastapi.models.permisos_model import User_Ruta_Access
10
10
  from files_server_fastapi.models.rutas_model import Rutas
11
11
  from files_server_fastapi.models.area_model import Area
12
+ from files_server_fastapi.models.users_extend_model import Users_extend
12
13
 
13
14
  router = APIRouter()
14
15
 
@@ -30,10 +31,14 @@ async def create_acl(
30
31
  """
31
32
  Crea o actualiza los accesos (ACLs) enviados desde el frontend.
32
33
  """
33
- # 0. Validar que el usuario existe en la BD
34
- user_result = await db.execute(select(User).where(User.id == req.user_id))
35
- if not user_result.scalars().first():
36
- raise HTTPException(status_code=404, detail=f"El usuario con ID {req.user_id} no existe en la base de datos.")
34
+ # 0. Traducir el ID que manda el frontend (users_extend.id) al verdadero user_id de la tabla Users
35
+ ext_result = await db.execute(select(Users_extend).where(Users_extend.id == req.user_id))
36
+ user_ext_obj = ext_result.scalars().first()
37
+
38
+ if not user_ext_obj:
39
+ raise HTTPException(status_code=404, detail=f"No se encontró ninguna extensión de usuario activa con el ID {req.user_id}.")
40
+
41
+ real_user_id = user_ext_obj.user_id
37
42
 
38
43
  # 1. Verificar si el Área existe para crear la Ruta adecuadamente
39
44
  area_result = await db.execute(select(Area).where(Area.area_name.ilike(req.area)))
@@ -76,7 +81,7 @@ async def create_acl(
76
81
  # 3. Asignar el ACL en User_Ruta_Access
77
82
  acl_result = await db.execute(
78
83
  select(User_Ruta_Access)
79
- .where(User_Ruta_Access.user_id == req.user_id)
84
+ .where(User_Ruta_Access.user_id == real_user_id)
80
85
  .where(User_Ruta_Access.ruta_id == ruta_obj.id)
81
86
  )
82
87
  existing_acl = acl_result.scalars().first()
@@ -86,7 +91,7 @@ async def create_acl(
86
91
  processed_acls.append(existing_acl.id)
87
92
  else:
88
93
  new_acl = User_Ruta_Access(
89
- user_id=req.user_id,
94
+ user_id=real_user_id,
90
95
  ruta_id=ruta_obj.id,
91
96
  access_type=db_access_type
92
97
  )
@@ -1,5 +1,13 @@
1
- # Directorio maestro (ruta de red Samba vista desde Windows)
2
- BASE_DIR = r"\\192.168.1.122\Compartido"
1
+ import os
2
+ from dotenv import load_dotenv
3
+
4
+ load_dotenv()
5
+
6
+ # Directorio maestro (ruta local en servidor Linux)
7
+ BASE_DIR = os.getenv("FILES_BASE_DIR")
8
+ # Directorio compartido para clientes Windows (Samba UNC Path)
9
+ SMB_BASE_DIR = os.getenv("SMB_BASE_DIR")
10
+
3
11
 
4
12
  # Mapeo extensión → protocolo de Office
5
13
  OFFICE_PROTOCOLS = {
@@ -1,6 +1,6 @@
1
1
  import os
2
2
  from fastapi import APIRouter, HTTPException, Depends
3
- from files_server_fastapi.files.constants import BASE_DIR, OFFICE_PROTOCOLS
3
+ from files_server_fastapi.files.constants import BASE_DIR, SMB_BASE_DIR, OFFICE_PROTOCOLS
4
4
  from files_server_fastapi.files.dependencies import check_folder_access
5
5
 
6
6
  router = APIRouter()
@@ -35,7 +35,7 @@ async def get_open_url(
35
35
 
36
36
  if office_protocol:
37
37
  subpath_win = safe_subpath.replace("/", "\\")
38
- unc_path = f"{BASE_DIR}\\{area.upper()}\\{subpath_win}\\{safe_filename}" if safe_subpath else f"{BASE_DIR}\\{area.upper()}\\{safe_filename}"
38
+ unc_path = f"{SMB_BASE_DIR}\\{area.upper()}\\{subpath_win}\\{safe_filename}" if safe_subpath else f"{SMB_BASE_DIR}\\{area.upper()}\\{safe_filename}"
39
39
  return {
40
40
  "type": "office",
41
41
  "protocol": office_protocol,
@@ -628,7 +628,7 @@ wheels = [
628
628
 
629
629
  [[package]]
630
630
  name = "files-server-fastapi"
631
- version = "0.1.6"
631
+ version = "0.1.7"
632
632
  source = { editable = "." }
633
633
  dependencies = [
634
634
  { name = "oauth2fast-fastapi" },