Skip to content

[FEAT] Add models, URLs, and CRUD endpoints for handling achievements of political figures#25

Open
Appyouz wants to merge 2 commits intoosnepal:mainfrom
Appyouz:feat/issue-13-achievements
Open

[FEAT] Add models, URLs, and CRUD endpoints for handling achievements of political figures#25
Appyouz wants to merge 2 commits intoosnepal:mainfrom
Appyouz:feat/issue-13-achievements

Conversation

@Appyouz
Copy link
Contributor

@Appyouz Appyouz commented Oct 28, 2025

This Pull Request (PR) is to add the Achievement models, serializers, views, and URLs to handle achievements for political figures. This work closes #13.

I followed the plan to split up the files and add the new models and endpoints.


File Changes

  1. Models Split:

    • Replaced political_figure/models.py with new files:

      • political_figure/models/__init__.py (just for importing everything)
      • political_figure/models/core.py (has the existing PoliticalFigure model)
      • political_figure/models/achievements.py (New file for the Achievement model)
  2. Views Split:

    • Replaced political_figure/views.py with new files:

      • political_figure/views/__init__.py (just for importing everything)
      • political_figure/views/core.py (has the existing views)
      • political_figure/views/achievements.py (New file for the achievement views)

New Model: Achievement

I made a new model in political_figure/models/achievements.py. It inherits from BaseModel.

Field Name Type Notes
political_figure ForeignKey Links to the political figure.
title CharField The name of the achievement.
category TextChoices Added a category choice list.
description TextField More details.
year IntegerField To validate 4-digit year
awarding_body CharField Who gave the award.
evidence_link URLField A link to prove it.
status TextChoices Added a status choice list.

Serializer and Validation

I created the AchievementSerializer.

I also added a custom validation in the serializer for the year field to make sure people enter a proper 4-digit year (like 2025 AD or 2082 BS) and not something too short or too long.

- Implements full CRUD for the new Achievement model with custom year validation.
- Secures all modification actions (POST/PATCH/DELETE) using the new IsAdminOrSuper permission.
- Restructures the political_figure app, splitting models and views into core/ and feature specific files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant