-
-
Notifications
You must be signed in to change notification settings - Fork 32
Add Accomplishment model and API endpoints for Feature #48 #530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,3 +46,4 @@ docs/build | |
| *.pyc | ||
|
|
||
| .vscode | ||
| TODO.md | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Generated by Django 4.2.16 on 2026-01-16 06:58 | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
| import uuid | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [('core', '0045_wintype')] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='Accomplishment', | ||
| fields=[ | ||
| ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)), | ||
| ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created at')), | ||
| ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated at')), | ||
| ('title', models.CharField(db_comment='Title of the accomplishment', help_text='Title of the accomplishment', max_length=255)), | ||
| ('description', models.TextField(db_comment='Detailed description of the accomplishment', help_text='Detailed description of the accomplishment')), | ||
| ('url', models.URLField(db_comment='URL link to the accomplishment', help_text='URL link to the accomplishment')), | ||
| ('accomplished_on', models.DateTimeField(db_comment='Date when the accomplishment was achieved', help_text='Date when the accomplishment was achieved')), | ||
| ('project', models.ForeignKey(db_comment='Project this accomplishment belongs to', help_text='Project this accomplishment belongs to', on_delete=django.db.models.deletion.PROTECT, related_name='accomplishments', to='core.project')), | ||
| ], | ||
| options={ | ||
| 'indexes': [models.Index(fields=['project'], name='core_accomp_project_idx'), models.Index(fields=['accomplished_on'], name='core_accomp_date_idx')], | ||
| }, | ||
| ), | ||
| migrations.AddConstraint( | ||
| model_name='accomplishment', | ||
| constraint=models.UniqueConstraint(fields=('project', 'title'), name='unique_accomplishment_per_project'), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 0045_wintype | ||
| 0046_accomplishment_and_more |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
|
|
||
| class AbstractBaseModel(models.Model): | ||
| """ | ||
| Base abstract model, that has `uuid` instead of `id` and included `created_at`, `updated_at` fields. | ||
| Base abstract model, that has `uuid` instead of `id` fields. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These lines shouldn't be changed since it's not part of the issue. |
||
| """ | ||
|
|
||
| uuid = models.UUIDField( | ||
|
|
@@ -507,6 +507,52 @@ def __str__(self): | |
| return self.title | ||
|
|
||
|
|
||
| class Accomplishment(AbstractBaseModel): | ||
| """ | ||
| Project accomplishments and milestones | ||
| """ | ||
|
|
||
| project = models.ForeignKey( | ||
| Project, | ||
| on_delete=models.PROTECT, | ||
| related_name="accomplishments", | ||
| db_comment="Project this accomplishment belongs to", | ||
| help_text="Project this accomplishment belongs to", | ||
| ) | ||
| title = models.CharField( | ||
| max_length=255, | ||
| db_comment="Title of the accomplishment", | ||
| help_text="Title of the accomplishment", | ||
| ) | ||
| description = models.TextField( | ||
| db_comment="Detailed description of the accomplishment", | ||
| help_text="Detailed description of the accomplishment", | ||
| ) | ||
| url = models.URLField( | ||
| db_comment="URL link to the accomplishment", | ||
| help_text="URL link to the accomplishment", | ||
| ) | ||
| accomplished_on = models.DateTimeField( | ||
| db_comment="Date when the accomplishment was achieved", | ||
| help_text="Date when the accomplishment was achieved", | ||
| ) | ||
|
|
||
| class Meta: | ||
| indexes = [ | ||
| models.Index(fields=["project"], name="core_accomp_project_idx"), | ||
| models.Index(fields=["accomplished_on"], name="core_accomp_date_idx"), | ||
| ] | ||
|
Comment on lines
+541
to
+544
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not necessary to add these indexes. Django already adds some default ones that overlap these. |
||
| constraints = [ | ||
| models.UniqueConstraint( | ||
| fields=["project", "title"], | ||
| name="unique_accomplishment_per_project", | ||
| ) | ||
| ] | ||
|
|
||
| def __str__(self): | ||
| return self.title | ||
|
|
||
|
|
||
| class ProjectProgramAreaXref(AbstractBaseModel): | ||
| project = models.ForeignKey(Project, on_delete=models.CASCADE) | ||
| program_area = models.ForeignKey(ProgramArea, on_delete=models.CASCADE) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks you have a local file to ignore. It shouldn't be committed to the project though.
You can move this line to
.git/info/excludeso it applies only to your local repo.