This is a page for leaving comments. Users can add comments with various features, and all the entered comments are saved in a relational database (DB), including user data for identification.
-
Users can leave comments with the following fields:
- User Name (alphanumeric characters) - required field.
- E-mail (email format) - required field.
- Home page (URL format) - optional field.
- CAPTCHA (alphanumeric characters) - image and required field.
- Text (the main message text) - required field. HTML tags except the allowed ones are not allowed.
-
The main page of the application has the following requirements:
- Comments can have multiple replies (cascade display).
- Top-level comments (not replies) are displayed in a table format with the ability to sort by the following fields: User Name, E-mail, and Date added (both in ascending and descending order).
- Messages are paginated with 25 messages per page.
-
JavaScript:
- Server-side and client-side validation of input data.
- Panel with buttons for HTML tags (
[i]
,[strong]
,[code]
,[a]
).
-
File Handling:
- Users can add an image or a text file to their comment.
- Images resizes proportionally to a maximum size of 320x240 pixels if the uploaded image is larger. Allowed file formats are JPG, GIF, and PNG.
- Text files should not exceed 100 KB in size, and the only allowed format is TXT.
- File preview includes visual effects (e.g. Lightbox2).
-
Regular Expressions:
- Users can use the following allowed HTML tags in their messages:
<a href="" title=""> </a> <code> </code> <i> </i> <strong> </strong>
. - There is validation to ensure proper closing of tags.
- Users can use the following allowed HTML tags in their messages:
The project utilizes the following technologies and tools:
- Backend:
- Python programming language (OOP);
- Django framework with the django-simple-captcha extension;
- MySQL database (Django ORM).
- Frontend:
- HTML & CSS;
- JavaScript;
- Bootstrap 5.
- Git for version control.
To run this project, you will need to add the following environment variables:
SECRET_KEY
DB_HOST
DB_NAME
DB_USER
DB_PASSWORD
Look at the file_env_example.txt
To get started with the project, follow these steps:
-
Clone the repository:
git clone https://github.com/Gubchik123/dZENcode-test-task.git
-
Go to the project directory:
cd dZENcode-test-task
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up the database connection and configurations according to the selected database engine. Apply migrations
python manage.py migrate
-
Run the Django development server:
python manage.py runserver
Note: Don't forget about environment variables
-
Access the application in your web browser at
http://127.0.0.1:8000
(or the appropriate URL based on your Django configuration).
The "Spa comments" is a feature-rich web application built using Django, JavaScript, and MySQL. It allows users to leave comments with various options, ensures data validation and security, and provides a user-friendly interface with interactive elements.