示例#1
0
 def test_print_email_notification_in_console(self):
     Geopackage.objects.create(
         creator=self.creator,
         name="spiky polygons",
         description="A GeoPackage for testing purpose",
         thumbnail_image=self.thumbnail,
         file=self.file
     )
     gpkg = Geopackage.objects.first()
     resource_notify(gpkg, resource_type='GeoPackage')
     Review.objects.create(
         reviewer=self.staff,
         resource=gpkg,
         comment="Rejected for testing purpose")
     gpkg.require_action = True
     gpkg.save()
     resource_update_notify(gpkg, self.creator, self.staff,
                            resource_type='GeoPackage')
     Review.objects.create(
         reviewer=self.staff,
         resource=gpkg,
         comment="Approved! This is for testing purpose")
     gpkg.approved = True
     gpkg.save()
     resource_update_notify(gpkg, self.creator, self.staff,
                            resource_type='GeoPackage')
示例#2
0
 def test_print_email_notification_in_console(self):
     Model.objects.create(creator=self.creator,
                          name="flooded buildings extractor",
                          description="A Model for testing purpose",
                          thumbnail_image=self.thumbnail,
                          file=self.file)
     model = Model.objects.first()
     resource_notify(model, resource_type='Model')
     Review.objects.create(reviewer=self.staff,
                           resource=model,
                           comment="Rejected for testing purpose")
     model.require_action = True
     model.save()
     resource_update_notify(model,
                            self.creator,
                            self.staff,
                            resource_type='Model')
     Review.objects.create(reviewer=self.staff,
                           resource=model,
                           comment="Approved! This is for testing purpose")
     model.approved = True
     model.save()
     resource_update_notify(model,
                            self.creator,
                            self.staff,
                            resource_type='Model')
示例#3
0
 def form_valid(self, form):
     obj = form.save(commit=False)
     obj.creator = self.request.user
     xml_parse = read_xml_style(obj.file)
     if xml_parse:
         # check if name exists
         name_exist = Style.objects.filter(
             name__iexact=xml_parse['name']).exists()
         if name_exist:
             obj.name = "%s_%s" % (xml_parse['name'].title(),
                                   get_random_string(length=5))
         else:
             obj.name = xml_parse['name'].title()
         style_type = StyleType.objects.filter(
             symbol_type=xml_parse['type']).first()
         if not style_type:
             style_type = StyleType.objects.create(
                 symbol_type=xml_parse['type'],
                 name=xml_parse['type'].title(),
                 description="Automatically created from '"
                             "'an uploaded Style file")
         obj.style_type = style_type
     obj.save()
     resource_notify(obj, self.resource_name)
     msg = _("The Style has been successfully created.")
     messages.success(self.request, msg, 'success', fail_silently=True)
     return HttpResponseRedirect(reverse('style_detail',
                                         kwargs={'pk': obj.id}))
示例#4
0
 def test_send_email_new_style_notification(self):
     resource_notify(self.style_new, resource_type='Style')
     self.assertEqual(len(mail.outbox), 1)
     self.assertEqual(mail.outbox[0].subject,
                      "A new Style has been created by creator.")
     self.assertIn("Style name is: New Cube Style", mail.outbox[0].body)
     self.assertIn("Style description is: This is a new cube",
                   mail.outbox[0].body)
示例#5
0
    def form_valid(self, form):
        """
        Update the style type according to the style XML file.
        """

        obj = form.save(commit=False)
        xml_parse = read_xml_style(obj.file)
        if xml_parse:
            obj.style_type = StyleType.objects.filter(
                symbol_type=xml_parse['type']).first()
        obj.require_action = False
        obj.approved = False
        obj.save()
        resource_notify(obj, created=False, resource_type=self.resource_name)
        msg = _("The Style has been successfully updated.")
        messages.success(self.request, msg, 'success', fail_silently=True)
        return HttpResponseRedirect(reverse_lazy('style_detail',
                                                 kwargs={'pk': obj.id}))