""".format(js))
+ else:
+ html = Template("""""")
return mark_safe(html.substitute(link=value,name=name))
@@ -33,7 +54,7 @@ class Meta:
'label'
)
- download_url = forms.FileField(required=False, widget=PdfWidget, help_text="Upload map download file. PDF is recommended. 75MB max size.")
+ download_url = forms.FileField(required=False, widget=PdfWidget, help_text="Upload map download file. PDF is recommended. 75MB max size. Overwriting files is not allowed. Delete the record and create a new one with the new file if you are attempting to overwrite.")
# FILE UPLOAD FOR DOWNLOAD FILE (PDF SUGGESTED)
# boto3 s3 object
diff --git a/src/data_hub/tnris_org/admin.py b/src/data_hub/tnris_org/admin.py
index e04214de..c88435d4 100644
--- a/src/data_hub/tnris_org/admin.py
+++ b/src/data_hub/tnris_org/admin.py
@@ -52,7 +52,7 @@ def image_url_link(self, obj):
""".replace('{id}', htmlId)
js = format_html(js)
return format_html(
- u'{0}COPY URL',
+ u'{0}
',
js,
htmlId,
htmlId,
obj.document_url
)
- def tiny_preview(self, obj):
- # tiny preview of .pdf files errors/breaks on page load when src is cached.
- # this means all tiny previews display on hard reload, but .pdfs don't on
- # normal reload. so, we append a current datetime query string to the request
- # so the browser recognizes each load as a new request and doesn't load the
- # cached version.
- no_cache = str(datetime.today())
- return format_html(
- u'',
- obj.document_url,
- no_cache
- )
-
@admin.register(TnrisTraining)
class TnrisTrainingAdmin(admin.ModelAdmin):
diff --git a/src/data_hub/tnris_org/forms.py b/src/data_hub/tnris_org/forms.py
index 3784ef20..57da8329 100644
--- a/src/data_hub/tnris_org/forms.py
+++ b/src/data_hub/tnris_org/forms.py
@@ -32,7 +32,7 @@ def render(self, name, value, attrs=None):
if value is None:
html = Template("""""")
else:
- html = Template("""{0}COPY URL """.format(js))
+ html = Template("""{0}
""".format(js))
return mark_safe(html.substitute(link=value,name=name))
@@ -51,7 +51,7 @@ def render(self, name, value, attrs=None):
if value is None:
html = Template("""""")
else:
- html = Template("""{0}COPY URL """.format(js))
+ html = Template("""{0}
""".format(js))
return mark_safe(html.substitute(link=value,name=name))
@@ -69,7 +69,7 @@ class Meta:
model = TnrisImage
fields = ('__all__')
- image_url = forms.FileField(required=False, widget=PictureWidget, help_text="Choose an image file and 'Save' this form to upload & save it to the database. Attempting to overwrite with a new file will only create a new record.")
+ image_url = forms.FileField(required=False, widget=PictureWidget, help_text="Choose an image file and 'Save' this form to upload & save it to the database. Attempting to overwrite with a new file will only create a new record. The best method to overwrite would be to delete the existing file and re-upload a new file with the same name.")
# boto3 s3 object
client = boto3.client('s3')
@@ -128,7 +128,8 @@ class Meta:
model = TnrisDocument
fields = ('__all__')
- document_url = forms.FileField(required=False, widget=DocumentWidget, help_text="Choose a document file and 'Save' this form to upload & save it to the database. Attempting to overwrite with a new file will only create a new record.")
+ document_url = forms.FileField(required=False, widget=DocumentWidget, help_text="Choose a document file and 'Save' this form to upload & save it to the database. Attempting to overwrite with a new file will only create a new record. The best method to overwrite would be to delete the existing file and re-upload a new file with the same name.")
+ sgm_note = forms.BooleanField(required=False, label="GIS Solutions Group Notes", help_text="Check this box to identify this as a Solutions Group Notes document. This is required to view the document on tnris.org. Be sure to name the file correctly - 'YYYY-MM-DD-GIS-SG-Meeting-Notes.pdf'. The file name is important for the order these documents are presented on tnris.org.")
# boto3 s3 object
client = boto3.client('s3')
diff --git a/src/data_hub/tnris_org/migrations/0024_tnrisdocument_sgm_note.py b/src/data_hub/tnris_org/migrations/0024_tnrisdocument_sgm_note.py
new file mode 100644
index 00000000..31fe1605
--- /dev/null
+++ b/src/data_hub/tnris_org/migrations/0024_tnrisdocument_sgm_note.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.0.13 on 2020-01-31 17:42
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('tnris_org', '0023_tnrisgiocalendarevent_community_meeting_agenda_url'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='tnrisdocument',
+ name='sgm_note',
+ field=models.BooleanField(default=False, verbose_name='Solutions Group Note'),
+ ),
+ ]
diff --git a/src/data_hub/tnris_org/models.py b/src/data_hub/tnris_org/models.py
index 4a8b128f..de33ce9d 100644
--- a/src/data_hub/tnris_org/models.py
+++ b/src/data_hub/tnris_org/models.py
@@ -80,6 +80,11 @@ class Meta:
'Document URL',
max_length=255,
)
+ sgm_note = models.BooleanField(
+ 'Solutions Group Note',
+ default=False,
+ null=False
+ )
created = models.DateTimeField(
'Created',
auto_now_add=True
diff --git a/src/data_hub/tnris_org/serializers.py b/src/data_hub/tnris_org/serializers.py
index 95dd73cf..9252a0c5 100644
--- a/src/data_hub/tnris_org/serializers.py
+++ b/src/data_hub/tnris_org/serializers.py
@@ -5,7 +5,8 @@
TnrisForumTraining,
TnrisInstructorType,
CompleteForumTrainingView,
- TnrisGioCalendarEvent
+ TnrisGioCalendarEvent,
+ TnrisDocument
)
from datetime import datetime
@@ -148,3 +149,14 @@ def get_pretty_time(self, obj):
pt = "%s-%s" % (st.strftime('%I:%M%p').lstrip("0"),
et.strftime('%I:%M%p').lstrip("0"))
return pt
+
+
+class TnrisSGMDocumentSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = TnrisDocument
+ fields = ('document_id',
+ 'document_name',
+ 'document_url',
+ 'sgm_note',
+ 'created',
+ 'last_modified',)
diff --git a/src/data_hub/tnris_org/urls.py b/src/data_hub/tnris_org/urls.py
index 895509f4..f0063ffa 100644
--- a/src/data_hub/tnris_org/urls.py
+++ b/src/data_hub/tnris_org/urls.py
@@ -24,6 +24,7 @@
TnrisInstructorTypeViewSet,
CompleteForumTrainingViewSet,
TnrisGioCalendarEventViewSet,
+ TnrisSGMDocumentViewSet,
)
router = routers.DefaultRouter(trailing_slash=False)
@@ -32,6 +33,7 @@
router.register(r'complete_forum_training/?', CompleteForumTrainingViewSet, base_name="CompleteForumTrainingView")
router.register(r'instructor_type/?', TnrisInstructorTypeViewSet, base_name="TnrisInstructorType")
router.register(r'gio_calendar/?', TnrisGioCalendarEventViewSet, base_name="TnrisGioCalendarEvent")
+router.register(r'sgm_note/?', TnrisSGMDocumentViewSet, base_name="TnrisDocument")
schema_view = get_swagger_view(title='TNRIS.org API')
diff --git a/src/data_hub/tnris_org/viewsets.py b/src/data_hub/tnris_org/viewsets.py
index 255172e5..afb4e12d 100644
--- a/src/data_hub/tnris_org/viewsets.py
+++ b/src/data_hub/tnris_org/viewsets.py
@@ -7,14 +7,16 @@
TnrisForumTraining,
TnrisInstructorType,
CompleteForumTrainingView,
- TnrisGioCalendarEvent
+ TnrisGioCalendarEvent,
+ TnrisDocument
)
from .serializers import (
TnrisTrainingSerializer,
TnrisForumTrainingSerializer,
TnrisInstructorTypeSerializer,
CompleteForumTrainingViewSerializer,
- TnrisGioCalendarEventSerializer
+ TnrisGioCalendarEventSerializer,
+ TnrisSGMDocumentSerializer
)
@@ -130,4 +132,19 @@ def get_queryset(self):
args[field] = value
# get records using query. order by chronological start
queryset = TnrisGioCalendarEvent.objects.filter(**args).order_by('start_date', 'start_time')
- return queryset
\ No newline at end of file
+ return queryset
+
+
+class TnrisSGMDocumentViewSet(viewsets.ReadOnlyModelViewSet):
+ """
+ Retrieve all Solutions Group Meeting Documents for tnris.org frontend
+ """
+ serializer_class = TnrisSGMDocumentSerializer
+ http_method_names = ['get']
+
+ def get_queryset(self):
+ # get records using query
+ args = {'sgm_note': True}
+ # order by document file name
+ queryset = TnrisDocument.objects.filter(**args).order_by('document_name')
+ return queryset