fixed linting issues
This commit is contained in:
Binary file not shown.
@@ -1,10 +1,9 @@
|
||||
# modules/admin/api.py
|
||||
from typing import Annotated
|
||||
from fastapi import APIRouter, Depends, Body # Import Body
|
||||
from fastapi import APIRouter, Depends # Import Body
|
||||
from pydantic import BaseModel # Import BaseModel
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import Base, get_db
|
||||
from modules.auth.models import User, UserRole
|
||||
from core.database import get_db
|
||||
from modules.auth.dependencies import admin_only
|
||||
from .tasks import cleardb
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
# modules/auth/api.py
|
||||
from fastapi import APIRouter, Cookie, Depends, HTTPException, status, Request, Response
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from fastapi.security import OAuth2PasswordRequestForm
|
||||
from jose import JWTError
|
||||
from modules.auth.models import User
|
||||
@@ -7,7 +7,7 @@ from modules.auth.schemas import UserCreate, UserResponse, Token, RefreshTokenRe
|
||||
from modules.auth.services import create_user
|
||||
from modules.auth.security import TokenType, get_current_user, oauth2_scheme, create_access_token, create_refresh_token, verify_token, authenticate_user, blacklist_tokens
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import Annotated, Optional
|
||||
from typing import Annotated
|
||||
from core.database import get_db
|
||||
from datetime import timedelta
|
||||
from core.config import settings # Assuming settings is defined in core.config
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# modules/auth/dependencies.py
|
||||
from fastapi import Depends, HTTPException, status
|
||||
from fastapi import Depends
|
||||
from modules.auth.security import get_current_user
|
||||
from modules.auth.schemas import UserRole
|
||||
from modules.auth.models import User
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -5,7 +5,6 @@ from datetime import datetime
|
||||
from typing import List, Optional
|
||||
from modules.auth.dependencies import get_current_user
|
||||
from core.database import get_db
|
||||
from core.exceptions import not_found_exception
|
||||
from modules.auth.models import User
|
||||
from modules.calendar.schemas import CalendarEventCreate, CalendarEventUpdate, CalendarEventResponse
|
||||
from modules.calendar.service import create_calendar_event, get_calendar_event_by_id, get_calendar_events, update_calendar_event, delete_calendar_event
|
||||
|
||||
@@ -46,9 +46,9 @@ def get_calendar_events(db: Session, user_id: int, start: datetime | None, end:
|
||||
query = query.filter(
|
||||
or_(
|
||||
# Case 1: Event has duration and overlaps
|
||||
(CalendarEvent.end != None) & (CalendarEvent.start < end) & (CalendarEvent.end > start),
|
||||
(CalendarEvent.end is not None) & (CalendarEvent.start < end) & (CalendarEvent.end > start),
|
||||
# Case 2: Event is a point event within the range
|
||||
(CalendarEvent.end == None) & (CalendarEvent.start >= start) & (CalendarEvent.start < end)
|
||||
(CalendarEvent.end is None) & (CalendarEvent.start >= start) & (CalendarEvent.start < end)
|
||||
)
|
||||
)
|
||||
# If only start is provided, filter events starting on or after start
|
||||
@@ -63,9 +63,9 @@ def get_calendar_events(db: Session, user_id: int, start: datetime | None, end:
|
||||
query = query.filter(
|
||||
or_(
|
||||
# Event ends before the specified end time
|
||||
(CalendarEvent.end != None) & (CalendarEvent.end <= end),
|
||||
(CalendarEvent.end is not None) & (CalendarEvent.end <= end),
|
||||
# Point event occurs before the specified end time
|
||||
(CalendarEvent.end == None) & (CalendarEvent.start < end)
|
||||
(CalendarEvent.end is None) & (CalendarEvent.start < end)
|
||||
)
|
||||
)
|
||||
# Alternative interpretation for "ending before end": include events that *start* before end
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -11,7 +11,6 @@ from modules.auth.models import User
|
||||
from modules.nlp.service import process_request, ask_ai, save_chat_message, get_chat_history, MessageSender
|
||||
# Import the response schema and the new ChatMessage model for response type hinting
|
||||
from modules.nlp.schemas import ProcessCommandRequest, ProcessCommandResponse
|
||||
from modules.nlp.models import ChatMessage # Import ChatMessage model
|
||||
from modules.calendar.service import create_calendar_event, get_calendar_events, update_calendar_event, delete_calendar_event
|
||||
from modules.calendar.models import CalendarEvent
|
||||
from modules.calendar.schemas import CalendarEventCreate, CalendarEventUpdate
|
||||
@@ -19,7 +18,18 @@ from modules.calendar.schemas import CalendarEventCreate, CalendarEventUpdate
|
||||
from modules.todo import service as todo_service
|
||||
from modules.todo.models import Todo
|
||||
from modules.todo.schemas import TodoCreate, TodoUpdate
|
||||
from pydantic import BaseModel
|
||||
from datetime import datetime
|
||||
|
||||
class ChatMessageResponse(BaseModel):
|
||||
id: int
|
||||
sender: MessageSender # Use the enum directly
|
||||
text: str
|
||||
timestamp: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True # Allow Pydantic to work with ORM models
|
||||
|
||||
router = APIRouter(prefix="/nlp", tags=["nlp"])
|
||||
|
||||
# Helper to format calendar events (expects list of CalendarEvent models)
|
||||
@@ -217,20 +227,6 @@ def process_command(request_data: ProcessCommandRequest, current_user: User = De
|
||||
# ----------------------------------
|
||||
return ProcessCommandResponse(responses=[error_response])
|
||||
|
||||
# --- New Endpoint for Chat History ---
|
||||
# Define a Pydantic schema for the response (optional but good practice)
|
||||
from pydantic import BaseModel
|
||||
from datetime import datetime
|
||||
|
||||
class ChatMessageResponse(BaseModel):
|
||||
id: int
|
||||
sender: MessageSender # Use the enum directly
|
||||
text: str
|
||||
timestamp: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True # Allow Pydantic to work with ORM models
|
||||
|
||||
@router.get("/history", response_model=List[ChatMessageResponse])
|
||||
def read_chat_history(current_user: User = Depends(get_current_user), db: Session = Depends(get_db)):
|
||||
"""Retrieves the last 50 chat messages for the current user."""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
\
|
||||
# /home/cdp/code/MAIA/backend/modules/nlp/models.py
|
||||
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, Enum as SQLEnum
|
||||
from sqlalchemy import Column, Integer, Text, DateTime, ForeignKey, Enum as SQLEnum
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
import enum
|
||||
|
||||
Binary file not shown.
@@ -2,7 +2,6 @@
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from core.database import Base
|
||||
import datetime
|
||||
|
||||
class Todo(Base):
|
||||
__tablename__ = "todos"
|
||||
|
||||
Binary file not shown.
@@ -4,7 +4,7 @@ from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from core.database import get_db
|
||||
from core.exceptions import unauthorized_exception, not_found_exception, forbidden_exception
|
||||
from core.exceptions import not_found_exception, forbidden_exception
|
||||
from modules.auth.schemas import UserPatch, UserResponse
|
||||
from modules.auth.dependencies import get_current_user
|
||||
from modules.auth.models import User
|
||||
|
||||
Reference in New Issue
Block a user