def get_context_data(self, **kwargs): preprint = PreprintService.load(self.kwargs.get('guid')) # TODO - we shouldn't need this serialized_preprint value -- https://openscience.atlassian.net/browse/OSF-7743 kwargs['serialized_preprint'] = serialize_preprint(preprint) kwargs['change_provider_form'] = ChangeProviderForm(instance=preprint) kwargs['subjects'] = serialize_subjects(preprint.subject_hierarchy) return super(PreprintView, self).get_context_data(**kwargs)
def get_preprint_provider(self, obj): preprint_id = obj.get('preprint', None) if preprint_id: preprint = PreprintService.load(preprint_id) if preprint: provider = preprint.provider return {'url': provider.external_url, 'name': provider.name} return None
def get_preprint_provider(self, obj): preprint_id = obj.get('preprint', None) if preprint_id: preprint = PreprintService.load(preprint_id) if preprint: provider = preprint.provider return {'url': provider.external_url, 'name': provider.name} return None
def test_create_preprint_adds_log_if_published(self): public_project_payload = build_preprint_create_payload( self.public_project._id, self.provider._id, self.file_one_public_project._id, { 'is_published': True, 'subjects': [[SubjectFactory()._id]], }) res = self.app.post_json_api(self.url, public_project_payload, auth=self.user.auth) assert_equal(res.status_code, 201) preprint_id = res.json['data']['id'] preprint = PreprintService.load(preprint_id) log = preprint.node.logs[-2] assert_equal(log.action, 'preprint_initiated') assert_equal(log.params.get('preprint'), preprint_id)
def test_create_preprint_adds_log_if_published(self): public_project_payload = build_preprint_create_payload( self.public_project._id, self.provider._id, self.file_one_public_project._id, { 'is_published': True, 'subjects': [[SubjectFactory()._id]], } ) res = self.app.post_json_api(self.url, public_project_payload, auth=self.user.auth) assert_equal(res.status_code, 201) preprint_id = res.json['data']['id'] preprint = PreprintService.load(preprint_id) log = preprint.node.logs[-2] assert_equal(log.action, 'preprint_initiated') assert_equal(log.params.get('preprint'), preprint_id)
def get_object(self, queryset=None): return PreprintService.load(self.kwargs.get('guid'))