Skip to content

Commit 81cb10d

Browse files
Merge pull request #1401 from IFRCGo/develop
Mid-april deployment
2 parents 549b08b + 581881d commit 81cb10d

35 files changed

+464
-62
lines changed

CHANGELOG.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## Unreleased
88

9+
## 1.1.436
10+
11+
### Added
12+
- Tests trailing the changes
13+
- Adding Description + GeneralDocument to deployment.project
14+
- Add contact details to the 3w project
15+
- Countries of Field Report to review
16+
- Admin page - WikiJS Links
17+
- Adding reversion.register() decorators to 72 important models
18+
919
## 1.1.435
1020
## 1.1.431
1121

@@ -1949,8 +1959,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
19491959

19501960
## 0.1.20
19511961

1952-
[Unreleased]: https://github.com/IFRCGo/go-api/compare/1.1.435...HEAD
1953-
[1.1.435]: https://github.com/IFRCGo/go-api/compare/1.1.431...1.1.435
1962+
[Unreleased]: https://github.com/IFRCGo/go-api/compare/1.1.436...HEAD
1963+
[1.1.436]: https://github.com/IFRCGo/go-api/compare/1.1.435...1.1.436
1964+
[1.1.435]: https://github.com/IFRCGo/go-api/compare/1.1.434...1.1.435
1965+
[1.1.434]: https://github.com/IFRCGo/go-api/compare/1.1.433...1.1.434
1966+
[1.1.433]: https://github.com/IFRCGo/go-api/compare/1.1.432...1.1.433
1967+
[1.1.432]: https://github.com/IFRCGo/go-api/compare/1.1.431...1.1.432
19541968
[1.1.431]: https://github.com/IFRCGo/go-api/compare/1.1.430...1.1.431
19551969
[1.1.430]: https://github.com/IFRCGo/go-api/compare/1.1.429...1.1.430
19561970
[1.1.429]: https://github.com/IFRCGo/go-api/compare/1.1.428...1.1.429

api/admin.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ def appeals(self, instance):
208208
appeals.short_description = 'Appeals'
209209

210210
# To add the 'Notify subscribers now' button
211-
change_form_template = "admin/emergency_changeform.html"
211+
# WikiJS links added
212+
change_form_template = "admin/emergency_change_form.html"
213+
change_list_template = "admin/emergency_change_list.html"
212214

213215
# Overwriting readonly fields for Edit mode
214216
def changeform_view(self, request, *args, **kwargs):
@@ -292,6 +294,9 @@ class FieldReportAdmin(CompareVersionAdmin, RegionRestrictedAdmin, TranslationAd
292294
readonly_fields = ('report_date', 'created_at', 'updated_at')
293295
list_filter = [MembershipFilter]
294296
actions = ['create_events', 'export_field_reports', ]
297+
# WikiJS links added
298+
change_form_template = "admin/fieldreport_change_form.html"
299+
change_list_template = "admin/fieldreport_change_list.html"
295300

296301
def create_events(self, request, queryset):
297302
for report in queryset:
@@ -370,6 +375,10 @@ class AppealAdmin(CompareVersionAdmin, RegionRestrictedAdmin, TranslationAdmin):
370375
actions = ['create_events', 'confirm_events']
371376
autocomplete_fields = ('event', 'country',)
372377

378+
# WikiJS links added
379+
change_form_template = "admin/appeal_change_form.html"
380+
change_list_template = "admin/appeal_change_list.html"
381+
373382
def create_events(self, request, queryset):
374383
for appeal in queryset:
375384
event = models.Event.objects.create(
@@ -595,6 +604,10 @@ class SituationReportAdmin(CompareVersionAdmin, RegionRestrictedAdmin, Translati
595604
region_in = 'event__regions__in'
596605
autocomplete_fields = ('event',)
597606

607+
# WikiJS links added
608+
change_form_template = "admin/situationreport_change_form.html"
609+
change_list_template = "admin/situationreport_change_list.html"
610+
598611
def get_queryset(self, request):
599612
return super().get_queryset(request).select_related('type', 'event')
600613

@@ -611,9 +624,8 @@ class SituationReportTypeAdmin(CompareVersionAdmin):
611624
class CronJobAdmin(CompareVersionAdmin):
612625
list_display = ('name', 'created_at', 'num_result', 'status')
613626
search_fields = ('name', 'created_at',)
614-
readonly_fields = ('created_at',)
627+
readonly_fields = ('created_at', 'message_display',)
615628
list_filter = ('status', 'name')
616-
readonly_fields = ('message_display',)
617629

618630
def message_display(self, obj):
619631
style_class = {
@@ -757,6 +769,26 @@ def get_actions(self, request):
757769
return actions
758770

759771

772+
class CountryOfFieldReportToReviewAdmin(admin.ModelAdmin):
773+
list_display = ('country',)
774+
775+
@classmethod
776+
def has_delete_permission(cls, request, obj=None):
777+
return request.user.is_superuser
778+
779+
@classmethod
780+
def has_view_permission(cls, request, obj=None):
781+
return request.user.is_superuser
782+
783+
@classmethod
784+
def has_change_permission(cls, request, obj=None):
785+
return request.user.is_superuser
786+
787+
@classmethod
788+
def has_add_permission(cls, request, obj=None):
789+
return request.user.is_superuser
790+
791+
760792
admin.site.register(models.DisasterType, DisasterTypeAdmin)
761793
admin.site.register(models.Event, EventAdmin)
762794
admin.site.register(models.GDACSEvent, GdacsAdmin)
@@ -784,6 +816,7 @@ def get_actions(self, request):
784816
admin.site.register(models.MainContact, MainContactAdmin)
785817
admin.site.register(models.UserCountry, UserCountryAdmin)
786818
admin.site.register(models.UserRegion, UserRegionAdmin)
819+
admin.site.register(models.CountryOfFieldReportToReview, CountryOfFieldReportToReviewAdmin)
787820
# admin.site.register(Revision, RevisionAdmin)
788821

789822
admin.site.site_url = 'https://' + settings.FRONTEND_URL

api/drf_views.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from datetime import datetime
2+
from pytz import utc
13
from rest_framework.status import HTTP_201_CREATED, HTTP_200_OK
24
from rest_framework.generics import GenericAPIView, CreateAPIView, UpdateAPIView
35
from rest_framework.response import Response
@@ -55,7 +57,8 @@
5557
RequestChoices,
5658
EPISourceChoices,
5759
MainContact,
58-
UserCountry
60+
UserCountry,
61+
CountryOfFieldReportToReview,
5962
)
6063

6164
from .serializers import (
@@ -117,6 +120,8 @@
117120

118121
# Go Historical
119122
GoHistoricalSerializer,
123+
124+
CountryOfFieldReportToReviewSerializer,
120125
)
121126
from .logger import logger
122127

@@ -821,6 +826,9 @@ def map_many_to_many_relations(self, data):
821826
if prop in data:
822827
del data[prop]
823828

829+
if 'start_date' in data:
830+
data['start_date'] = datetime.strptime(data['start_date'], '%Y-%m-%dT%H:%M:%S.%f%z')\
831+
.replace(tzinfo=utc)
824832
return data, locations, meta, partners
825833

826834
def save_locations(self, instance, locations, is_update=False):
@@ -1023,3 +1031,12 @@ class GoHistoricalViewSet(viewsets.ReadOnlyModelViewSet):
10231031

10241032
def get_queryset(self):
10251033
return Event.objects.filter(appeals__isnull=False)
1034+
1035+
class CountryOfFieldReportToReviewViewset(viewsets.ReadOnlyModelViewSet):
1036+
queryset = CountryOfFieldReportToReview.objects.order_by('country')
1037+
serializer_class = CountryOfFieldReportToReviewSerializer
1038+
search_fields = ('country__name',) # for /docs
1039+
1040+
class Meta:
1041+
model = CountryOfFieldReportToReview
1042+
fields = ('country_id')
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Generated by Django 2.2.27 on 2022-04-12 13:33
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('api', '0151_merge_20220325_1027'),
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='CountryOfFieldReportToReview',
16+
fields=[
17+
('country', models.OneToOneField(on_delete=django.db.models.deletion.DO_NOTHING, primary_key=True, serialize=False, to='api.Country', verbose_name='country')),
18+
],
19+
options={
20+
'verbose_name': 'Country of Field Report to review',
21+
'verbose_name_plural': 'Countries of Field Report to review',
22+
},
23+
),
24+
]

0 commit comments

Comments
 (0)