Exemplo n.º 1
0
 def test_registrationschema_is_fine_with_same_name_but_different_version(
         self):
     RegistrationSchema(name='foo', schema={
         'foo': 42
     }, schema_version=1).save()
     RegistrationSchema(name='foo', schema={
         'foo': 42
     }, schema_version=2).save()
     assert_equal(RegistrationSchema.objects.filter(name='foo').count(), 2)
Exemplo n.º 2
0
 def test_reigstrationschema_uniqueness_is_enforced_in_the_database(self):
     RegistrationSchema(name='foo', schema={
         'foo': 42
     }, schema_version=1).save()
     assert_raises(
         ValidationError,
         RegistrationSchema(name='foo',
                            schema={
                                'bar': 24
                            },
                            schema_version=1).save)
Exemplo n.º 3
0
    def _notify_initiator(self):
        DraftRegistration = apps.get_model('osf.DraftRegistration')

        registration = self._get_registration()
        prereg_schema = RegistrationSchema.get_prereg_schema()
        draft = DraftRegistration.objects.get(registered_node=registration)

        if registration.registered_schema.filter(id=prereg_schema.id).exists():
            mails.send_mail(draft.initiator.username,
                            mails.PREREG_CHALLENGE_ACCEPTED,
                            user=draft.initiator,
                            registration_url=registration.absolute_url,
                            mimetype='html')
Exemplo n.º 4
0
    def _notify_initiator(self):
        DraftRegistration = apps.get_model('osf.DraftRegistration')

        registration = self._get_registration()
        prereg_schema = RegistrationSchema.get_prereg_schema()
        draft = DraftRegistration.objects.get(registered_node=registration)

        if registration.registered_schema.filter(id=prereg_schema.id).exists():
            mails.send_mail(draft.initiator.username,
                            mails.PREREG_CHALLENGE_ACCEPTED,
                            user=draft.initiator,
                            registration_url=registration.absolute_url,
                            mimetype='html')
Exemplo n.º 5
0
 def _email_template_context(self,
                             user,
                             node,
                             is_authorizer=False,
                             urls=None):
     registration = self._get_registration()
     prereg_schema = RegistrationSchema.get_prereg_schema()
     if registration.registered_schema.filter(pk=prereg_schema.pk).exists():
         return {
             'custom_message':
                 ' as part of the Preregistration Challenge (https://cos.io/prereg)'
         }
     else:
         return {}
Exemplo n.º 6
0
 def _email_template_context(self,
                             user,
                             node,
                             is_authorizer=False,
                             urls=None):
     registration = self._get_registration()
     prereg_schema = RegistrationSchema.get_prereg_schema()
     if registration.registered_schema.filter(pk=prereg_schema.pk).exists():
         return {
             'custom_message':
             ' as part of the Preregistration Challenge (https://cos.io/prereg)'
         }
     else:
         return {}
 def inactive_schema(self):
     reg_schema = RegistrationSchema(name='Test Schema (Inactive)',
                                     schema_version=1,
                                     active=False)
     reg_schema.save()
     return reg_schema
 def invisible_schema(self):
     reg_schema = RegistrationSchema(name='Test Schema (Invisible)',
                                     schema_version=1,
                                     visible=False)
     reg_schema.save()
     return reg_schema
 def out_dated_schema(self):
     reg_schema = RegistrationSchema(name='Prereg Challenge',
                                     schema_version=1)
     reg_schema.save()
     return reg_schema
Exemplo n.º 10
0
 def schema(self):
     schema = RegistrationSchema(name='foo',
                                 schema={'foo': 42},
                                 schema_version=1)
     schema.save()
     return schema