Repository: kartoza/prj.app

Issue:
We need a way to set a template for an organisation
Did I miss it? It seems I cannot set a template for the organization certificates? Can you make a property for the organization editor that lets me upload the template. Having a sample template which demarcates where the logos etc will be placed also will be good.

I think we must fall back to having Petra and Christo prep the certificates for us?




Discussion:
@timlinux I will update the form so you can upload a template for the organisation certificate

Resolving patch:
diff --git a/django_project/base/forms.py b/django_project/base/forms.py
--- a/django_project/base/forms.py
+++ b/django_project/base/forms.py
@@ -24,7 +24,8 @@ class Meta:
         fields = (
             'name',
             'image_file',
-            'gitter_room'
+            'gitter_room',
+            'signature',
         )
 
     def __init__(self, *args, **kwargs):
@@ -35,6 +36,7 @@ def __init__(self, *args, **kwargs):
                 'Project details',
                 Field('name', css_class="form-control"),
                 Field('image_file', css_class="form-control"),
+                Field('signature', css_class="form-control"),
                 Field('gitter_room', css_class="form-control"),
                 css_id='project-form')
         )
diff --git a/django_project/certification/forms.py b/django_project/certification/forms.py
--- a/django_project/certification/forms.py
+++ b/django_project/certification/forms.py
@@ -49,7 +49,8 @@ class Meta:
             'address',
             'country',
             'organisation_phone',
-            'organisation_owners'
+            'logo',
+            'organisation_owners',
         )
 
     def __init__(self, *args, **kwargs):
@@ -65,6 +66,7 @@ def __init__(self, *args, **kwargs):
                 Field('address', css_class='form-control'),
                 Field('country', css_class='form-control chosen-select'),
                 Field('organisation_phone', css_class='form-control'),
+                Field('logo', css_class='form-control'),
                 Field('organisation_owners', css_class='form-control'),
                 css_id='project-form')
         )
@@ -133,6 +135,7 @@ class Meta:
         model = CourseConvener
         fields = (
             'user',
+            'signature',
         )
 
     def __init__(self, *args, **kwargs):
@@ -144,7 +147,9 @@ def __init__(self, *args, **kwargs):
         layout = Layout(
             Fieldset(
                 form_title,
-                Field('user', css_class='form-control chosen-select'),)
+                Field('user', css_class='form-control chosen-select'),
+                Field('signature', css_class='form-control'),
+            )
         )
         self.helper.layout = layout
         self.helper.html5_required = False
@@ -247,11 +252,6 @@ def save(self, commit=True):
 
 class CourseForm(forms.ModelForm):
 
-    start_date = forms.DateField(
-        widget=forms.TextInput(attrs={'class': 'datepicker'}))
-    end_date = forms.DateField(
-        widget=forms.TextInput(attrs={'class': 'datepicker'}))
-
     # noinspection PyClassicStyleClass.
     class Meta:
         model = Course
@@ -261,6 +261,7 @@ class Meta:
             'training_center',
             'start_date',
             'end_date',
+            'template_certificate'
         )
 
     def __init__(self, *args, **kwargs):
@@ -275,8 +276,9 @@ def __init__(self, *args, **kwargs):
                 Field('course_convener',
                       css_class='form-control chosen-select'),
                 Field('training_center', css_class='form-control'),
-                Field('start_date', css_class='datepicker-here'),
-                Field('end_date', css_class='datepicker-here'),
+                Field('start_date', css_class='form-control datepicker-here'),
+                Field('end_date', css_class='form-control datepicker-here'),
+                Field('template_certificate', css_class='form-control'),
             )
         )
         self.helper.layout = layout
diff --git a/django_project/certification/views/certificate.py b/django_project/certification/views/certificate.py
--- a/django_project/certification/views/certificate.py
+++ b/django_project/certification/views/certificate.py
@@ -199,7 +199,7 @@ def certificate_pdf_view(request, **kwargs):
     if background is not None:
         page.drawImage(
             background, 0, 0, height=width, width=height,
-            preserveAspectRatio=True)
+            preserveAspectRatio=True, mask='auto')
     page.setFillColorRGB(0.1, 0.1, 0.1)
     page.setFont('Times-Roman', 18)
     # page.drawString(margin_left, 480, project.name)
@@ -209,12 +209,12 @@ def certificate_pdf_view(request, **kwargs):
     if project_logo is not None:
         page.drawImage(
             project_logo, 50, 500, width=50, height=50,
-            preserveAspectRatio=True)
+            preserveAspectRatio=True, mask='auto')
 
     if organisation_logo is not None:
         page.drawImage(
             organisation_logo, max_left, 500, height=50, width=50,
-            preserveAspectRatio=True, anchor='c')
+            preserveAspectRatio=True, anchor='c', mask='auto')
 
     page.setFont('Times-Bold', 26)
     page.drawCentredString(center, 480, 'Certificate of Completion')
@@ -242,12 +242,13 @@ def certificate_pdf_view(request, **kwargs):
         page.drawImage(
             project_owner_signature,
             (margin_left + 100), (margin_bottom + 70), width=100, height=70,
-            preserveAspectRatio=True, anchor='s')
+            preserveAspectRatio=True, anchor='s', mask='auto')
 
     if convener_signature is not None:
         page.drawImage(
             convener_signature, (margin_right - 200), (margin_bottom + 70),
-            width=100, height=70, preserveAspectRatio=True, anchor='s')
+            width=100, height=70, preserveAspectRatio=True, anchor='s',
+            mask='auto')
 
     page.setFont('Times-Italic', 12)
     page.drawCentredString(


Test patch: