-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2117 from IFRCGo/feature/ns-document
Add Additional fields in CountrykeyDocuments
- Loading branch information
Showing
7 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 3.2.25 on 2024-04-23 06:04 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0208_auto_20240404_0518'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='countrykeydocument', | ||
name='end_year', | ||
field=models.DateField(blank=True, null=True, verbose_name='End Year'), | ||
), | ||
migrations.AddField( | ||
model_name='countrykeydocument', | ||
name='year_text', | ||
field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Year Text'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
from django.db.models import OrderBy, F | ||
from django_filters import rest_framework as filters | ||
from rest_framework.filters import OrderingFilter | ||
|
||
|
||
class CharInFilter(filters.BaseInFilter, filters.CharFilter): | ||
pass | ||
|
||
|
||
class NullsLastOrderingFilter(OrderingFilter): | ||
def get_ordering(self, request, queryset, view): | ||
ordering = super().get_ordering(request, queryset, view) | ||
|
||
if ordering: | ||
nulls_last_ordering = [] | ||
for field in ordering: | ||
if field.startswith('-'): | ||
nulls_last_ordering.append(F(field[1:]).desc(nulls_last=True)) | ||
else: | ||
nulls_last_ordering.append(F(field).asc(nulls_last=True)) | ||
|
||
return nulls_last_ordering | ||
|
||
return ordering | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Generated by Django 3.2.25 on 2024-04-26 05:22 | ||
|
||
from django.db import migrations | ||
|
||
def delete_form_question(apps, schema_editor): | ||
FormQuestion = apps.get_model('per', 'FormQuestion') | ||
print(FormQuestion.objects.filter(question__icontains='Component Epidemic Preparedness').delete()) | ||
print(FormQuestion.objects.filter(question__icontains='Component performance').delete()) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('per', '0111_perdocumentupload_per'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
delete_form_question, | ||
reverse_code=migrations.RunPython.noop | ||
), | ||
] |