Fullstack Fruit & Veg Shop: A web application developed with HTML, CSS, and JavaScript for the frontend, and Django for the backend. Features include user authentication, a product catalogue, shopping cart functionality, and order management. and much more
Feat: Add tests and refactor UserBan model functionality
UserBan Model
Added new functionality:
Automatically bans a user permanently if no start or end date is provided, and marks this in the admin interface as a permanent ban.
Allowed banning from a specific start date to an end date.
Enabled banning a user for a specific number of days.
Implemented signals:
Automatically unbans a user when their BanUser record is deleted.
Admin Interface
Added form validation to prevent banning a user twice.
Made start and end dates optional for permanent bans.
Raised an error if only a start or end date is provided without the other.
If no dates are available because it is a permanent ban an N/A is shown for both dates
Helper Functions (for testing)
create_permanently_banned_user: Creates a permanently banned user.
create_temporarily_banned_user: Creates a temp-banned user with a date range.
create_banned_user_for_days: Bans a user for a specific number of days.
Added methods in the utils
current_time: Returns the current datetime
is_date_valid: Checks if a date is a datetime object.
Testing Enhancements
Modified start date and end date tests to ignore microseconds and seconds for consistency in comparison, ensuring tests no longer fail due to slight timing differences.
Added a comprehensive set of tests, including coverage for the newly refactored ban method.
Feat: Add tests and refactor UserBan model functionality
UserBan Model
Admin Interface
Helper Functions (for testing)
create_permanently_banned_user
: Creates a permanently banned user.create_temporarily_banned_user
: Creates a temp-banned user with a date range.create_banned_user_for_days
: Bans a user for a specific number of days.Added methods in the utils
current_time
: Returns the current datetimeis_date_valid
: Checks if a date is a datetime object.Testing Enhancements