Exemplo n.º 1
0
 def get_permissions(self, obj):
     user = self.context['request'].user
     ps = Intervention.permission_structure()
     permissions = InterventionPermissions(user=user,
                                           instance=self.instance,
                                           permission_structure=ps)
     return permissions.get_permissions()
 def test_invalid_partner_signed(self):
     """invalid if signed partner date and partner signatory
     and date after to today
     """
     intervention = Intervention(
         signed_by_partner_date=self.future_date,
         partner_authorized_officer_signatory=self.partner_user,
     )
     self.assertFalse(signed_date_valid(intervention))
 def test_valid_partner_signed(self):
     """Valid if signed partner date and partner signatory
     and date prior to today
     """
     intervention = Intervention(
         signed_by_partner_date=datetime.date(2001, 1, 1),
         partner_authorized_officer_signatory=self.partner_user,
     )
     self.assertTrue(signed_date_valid(intervention))
 def test_invalid_unicef_signed(self):
     """invalid if signed unicef date and unicef signatory
     and date after to today
     """
     intervention = Intervention(
         signed_by_unicef_date=self.future_date,
         unicef_signatory=self.unicef_user,
     )
     self.assertFalse(signed_date_valid(intervention))
 def test_valid_unicef_signed(self):
     """Valid if signed unicef date and unicef signatory
     and date prior to today
     """
     intervention = Intervention(
         signed_by_unicef_date=datetime.date(2001, 1, 1),
         unicef_signatory=self.unicef_user,
     )
     self.assertTrue(signed_date_valid(intervention))
 def test_invalid_all_signed_both_late(self):
     """invalid if both signed unicef/partner date and
     unicef/partner signatory and unicef/partner date after to today
     """
     intervention = Intervention(
         signed_by_unicef_date=self.future_date,
         unicef_signatory=self.unicef_user,
         signed_by_partner_date=self.future_date,
         partner_authorized_officer_signatory=self.partner_user,
     )
     self.assertFalse(signed_date_valid(intervention))
Exemplo n.º 7
0
 def test_save_model_create(self):
     self.assertFalse(Activity.objects.exists())
     agreement = AgreementFactory()
     ia = InterventionAdmin(Intervention, self.site)
     obj = Intervention(agreement=agreement)
     ia.save_model(self.request, obj, {}, False)
     self.assertTrue(
         Activity.objects.filter(action=Activity.CREATE).exists())
     activity = Activity.objects.first()
     self.assertEqual(activity.target, obj)
     self.assertEqual(activity.by_user, self.user)
     self.assertEqual(activity.change, {})
 def test_valid(self):
     """Valid if nothing signed"""
     intervention = Intervention()
     self.assertTrue(signed_date_valid(intervention))
Exemplo n.º 9
0
 def get_permissions(self, obj):
     user = self.context['request'].user
     ps = Intervention.permission_structure()
     permissions = InterventionPermissions(user=user, instance=self.instance, permission_structure=ps)
     return permissions.get_permissions()