project
EnProject
¶
Bases: SQLModel
Represents a project entity with details regarding its name, description, location, energy unit, CO2 unit, currency, geographical coordinates, and favorite status.
This class is intended to encapsulate core information about a project, such as its basic details and metadata, allowing for clear organization and representation in a database. The attributes include constraints for data validation.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the project must be between 1 and 100 characters. |
description |
str | None
|
An optional description of the project, up to 255 characters. |
country |
str
|
The country where the project is located, max length of 40 characters. |
unit_energy |
str
|
The energy unit associated with the project, max length of 10 characters. |
unit_co2 |
str
|
The CO2 unit associated with the project, max length of 10 characters. |
currency |
str
|
The currency used in the project, max length of 8 characters. |
longitude |
float
|
The longitude coordinate of the project location. Can be null. |
latitude |
float
|
The latitude coordinate of the project location. Can be null. |
is_favorite |
bool
|
Indicates if the project is marked as a favorite. Defaults to False. |
Source code in backend/app/project/model.py
EnProjectDB
¶
Bases: EnProject
Represents the EnProjectDB entity that defines the structure of the "projects" database table and inherits from the EnProject class.
This class is used to model and manipulate project data within the database, providing details such as project ID, associated user ID, creation timestamp, and update timestamp.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Unique identifier for the project. |
user_id |
int
|
ID of the user associated with the project. |
date_created |
datetime
|
Timestamp indicating when the project was created. |
date_updated |
datetime | None
|
Timestamp indicating when the project was last updated or None if not updated. |
Source code in backend/app/project/model.py
EnProjectUpdate
¶
Bases: EnProject
Represents an updated project with additional configurable fields.
This class is a subclass of EnProject
and is designed to provide
additional fields and configuration options for a project's update. It
allows for modification of the project's name, country, energy and CO2
units, currency, as well as geographical coordinates (longitude and
latitude).
Attributes:
Name | Type | Description |
---|---|---|
name |
str | None
|
Name of the project. This is an optional field that must have a length between 1 and 100 characters if provided. |
country |
str | None
|
Country associated with the project. This is an optional field that must have a length between 1 and 40 characters if provided. |
unit_energy |
str | None
|
Unit of energy measurement for the project. This is an optional field that must have a length between 1 and 10 characters if provided. |
unit_co2 |
str | None
|
Unit of CO2 measurement for the project. This is an optional field that must have a length between 1 and 10 characters if provided. |
currency |
str | None
|
Currency used for the project. This is a required field that must have a length between 1 and 8 characters. |
longitude |
float | None
|
Longitude value of the project's geographical location. This is an optional field. |
latitude |
float | None
|
Latitude value of the project's geographical location. This is an optional field. |