Updated README
This commit is contained in:
parent
ce8373f613
commit
ff4336f655
163
README.md
163
README.md
@ -16,139 +16,30 @@ This project was originally forked from [this project](https://github.com/MovieT
|
||||
|
||||
## File structure:
|
||||
```
|
||||
.
|
||||
├── app.py
|
||||
├── config.py
|
||||
├── definitions
|
||||
│ ├── attribute.py
|
||||
│ └── models.py
|
||||
├── functions
|
||||
│ ├── process_csv.py
|
||||
│ ├── validate_config.py
|
||||
│ └── validate_values.py
|
||||
├── routes
|
||||
│ ├── confirm_save.py
|
||||
│ ├── create.py
|
||||
│ ├── delete.py
|
||||
│ ├── export_csv.py
|
||||
│ ├── update.py
|
||||
│ ├── upload.py
|
||||
│ └── viewall.py
|
||||
├── static
|
||||
│ └── edited_csv.js
|
||||
└── templates
|
||||
├── create.html
|
||||
├── csv_preview.html
|
||||
├── delete.html
|
||||
├── update.html
|
||||
├── upload.html
|
||||
└── viewList.html
|
||||
```
|
||||
|
||||
## Files:
|
||||
|
||||
**`app.py`:**
|
||||
- The main application file.
|
||||
- The app does not start if the configuration is invalid.
|
||||
|
||||
**`config.py`:**
|
||||
Configuration of the app
|
||||
- Mysql details
|
||||
- The attributes of items are listed in a list, `item_attributes`
|
||||
- The list concists of items of the class `Attribute` and its sub-classes, defined in `definitions/attribute.py`
|
||||
|
||||
**`definitions/attribute.py`:**
|
||||
- Defines the type of data we use in the app
|
||||
- Classes:
|
||||
- `Attribute`:
|
||||
- Base class with basic properties.
|
||||
- Not used in the app directly.
|
||||
- `textAttribute`:
|
||||
- Sub-class of `Attribute` for string data.
|
||||
- Html input type is usually `text`.
|
||||
- `intAttribute`:
|
||||
- A type of `number`, but only accepts integers.
|
||||
- `floatAttribute`:
|
||||
- A type of `number`, but only accepts integers.
|
||||
- `dateAttribute`:
|
||||
- HTML input type `date`
|
||||
- `selectAttribute`:
|
||||
- For drop-down selection menu to choose from pre-defined options
|
||||
- Other data types are not defined now. They may be implemented in future versions, but not now.
|
||||
- The classes/subclass have their own `__init__` functions, as well as a `validate()` functions to validate the configuration
|
||||
- Additional validation is done in `functions/validate_config.py`
|
||||
|
||||
**`definitions/models.py`:**
|
||||
- Uses `SQLAlchemy` from `flask_sqlalchemy`
|
||||
- Handles creation of tables and managing its data
|
||||
- Function `create_asset_model` dynamically defines a class based on the configuration in `config.py`
|
||||
|
||||
**`functions/validate_config.py`:**
|
||||
- A function validate the configure file.
|
||||
- Returns "Ok" or some error message
|
||||
- Most of the validation is handled by the class's own `validate()`, but some things need external validation
|
||||
|
||||
**`functions/validate_values.py`:**
|
||||
- Checks for invalid values in data submitted by the user
|
||||
- Returns None or some error messages
|
||||
|
||||
**`functions/process_csv.py`:**
|
||||
- Extract data from the uploaded csv file
|
||||
- The delimiter is '|'
|
||||
|
||||
**`routes/viewall.py`** & **`templates/viewList.html`:**
|
||||
- Fetch and display all items in the db
|
||||
|
||||
**`routes/export_csv.py`**:
|
||||
- Download all the data as a csv file
|
||||
|
||||
**`routes/delete.py`** & **`templates/delete.html`:**
|
||||
- Delete a single item.
|
||||
- Preview the item and ask for confirmation before deletion
|
||||
|
||||
**`routes/create.py`** & **`templates/create.html`:**
|
||||
- Form to insert a new item to the db
|
||||
- Validate data on submit before insertion
|
||||
- Display validation errors
|
||||
|
||||
**`routes/update.py`** & **`templates/update.html`:**
|
||||
- Form to edit an existing item in the db
|
||||
- Validate data on submit before updating
|
||||
- Display validation errors
|
||||
|
||||
**`routes/upload.py`**, **`templates/upload.html`**, **`templates/csv_preview.html`**, **`static/edited_csv.js`:**
|
||||
- Upload a csv file
|
||||
- Check file format and data validity
|
||||
- Error messages in case of invalid file or data
|
||||
- If no errors and data is valid, proceed to redirect and preview the csv data in 2 tables:
|
||||
- New items:
|
||||
- Editable table
|
||||
- Submit in a hidden `form` after editing
|
||||
- Existing items:
|
||||
- Non-editable table
|
||||
- Not submitted in the form or added to db
|
||||
- The javascript function ensures the edited final data in the editable table is submitted instead of the original data from the file
|
||||
- Data is submitted to `/confirm_save`
|
||||
|
||||
**`routes/confirm_save.py`:**
|
||||
- Validate the submitted form data in the csv/table
|
||||
- Insert data to db in case of successful validation
|
||||
- Redirect to `templates/csv_preview.html` in case of validation errors.
|
||||
- `templates/csv_preview.html` will display the error messages.
|
||||
|
||||
## Requires fixing
|
||||
|
||||
- The csv uploading code is buggy
|
||||
|
||||
## To be implemented
|
||||
|
||||
**Edit a batch of items using csv:**
|
||||
- Same work-flow as adding new data from csv:
|
||||
- Upload csv
|
||||
- Validate
|
||||
- Preview existing items in an editable table
|
||||
- Preview non-existant items in a non-editable, non-submittable table
|
||||
- Submit edited table data
|
||||
- Validate data
|
||||
- Update items in db or show error messages
|
||||
- Can be done by reusing the code for adding new data from csv
|
||||
.
|
||||
├── app.py # Main application file
|
||||
├── config.py # Application configuration (database, item attributes)
|
||||
├── definitions/ # Definitions for attributes and database models
|
||||
│ ├── attribute.py # Attribute types (text, integer, date, select)
|
||||
│ └── models.py # SQLAlchemy models and dynamic table creation
|
||||
├── functions/ # Helper functions
|
||||
│ ├── process_csv.py # Extract and process CSV data
|
||||
│ ├── validate_config.py # Validate configuration file
|
||||
│ └── validate_values.py # Validate user input and CSV data
|
||||
├── routes/ # Flask routes
|
||||
│ ├── confirm_save.py # Save validated CSV data to the database
|
||||
│ ├── create.py # Add new items
|
||||
│ ├── delete.py # Delete items
|
||||
│ ├── export_csv.py # Export data as CSV
|
||||
│ ├── update.py # Edit existing items
|
||||
│ ├── upload.py # Upload and process CSV files
|
||||
│ └── viewall.py # View all items in the database
|
||||
├── static/ # Static files (e.g., JavaScript)
|
||||
│ └── edited_csv.js # JavaScript for editing CSV preview tables
|
||||
└── templates/ # HTML templates
|
||||
├── csv_preview.html # Preview and edit CSV data
|
||||
├── delete.html # Confirm item deletion
|
||||
├── item_form.html # Form for adding/editing items
|
||||
├── upload.html # Upload CSV file
|
||||
└── viewList.html # Home page (view all items)
|
||||
```
|
Loading…
Reference in New Issue
Block a user