Exemplo n.º 1
0
def view(request, project_id):
    project = project_api.get_project(project_api.id2uri(project_id))
    project = fetch_resources(project)
    badge = badge_api.get_badge(project['badge_uri'])
    badge = fetch_badge_resources(badge)
    feedback = project_api.get_project_feedback(project['uri'])
    for fb in feedback:
        if fb.get('expert_uri'):
            fb['expert'] = p2pu_user_api.get_user(fb['expert_uri'])
    can_revise = False
    can_give_feedback = False
    if request.session.get('user'):
        user_uri = request.session['user']['uri']
        if user_uri == project['author_uri']:
            can_revise = project_api.can_revise_project(project['uri'])
        can_give_feedback = project_api.ready_for_feedback(project['uri'])
        can_give_feedback &= user_uri in badge_api.get_badge_experts(badge['uri'])

    context = {
        'project': project,
        'badge': badge,
        'feedback': feedback,
        'can_revise': can_revise,
        'can_give_feedback': can_give_feedback
    }
    return render_to_response(
        'project/view.html',
        context,
        context_instance=RequestContext(request)
    )
Exemplo n.º 2
0
    def test_project_feedback_cycle(self):
        # create badge
        badge = badge_api.create_badge(**self.badge_values)
        badge_api.publish_badge(badge['uri'])
        user = p2pu_user_api.save_user('badgemaker', 'http://placeholdit.com/40x40', '*****@*****.**')

        # create project
        project_values = self.project_values.copy()
        project_values['badge_uri'] = badge['uri']
        project = project_api.create_project(**project_values)

        # get feedback - has to be zero, there was not any feedback submitted yet
        project_feedback = project_api.get_project_feedback(project['uri'])
        self.assertEqual(len(project_feedback), 0)

        # test that project can be revised - it can not, there has not been feedback given yet
        self.assertFalse(project_api.can_revise_project(project['uri']))

        # test that error is raised when revision is given - it has to be, there was no feedback given yet
        with self.assertRaises(Exception):
            project_api.revise_project(project['uri'], 'All better')

        # test that project is ready for feedback
        self.assertTrue(project_api.ready_for_feedback(project['uri']))

        # submit feedback
        project_api.submit_feedback(project['uri'], '/uri/user/badgemaker', 'Ugly', 'Bad', 'Good')
        project_feedback = project_api.get_project_feedback(project['uri'])

        self.assertEqual(len(project_feedback), 1)
        self.assertIn('good', project_feedback[0])
        self.assertIn('bad', project_feedback[0])
        self.assertIn('ugly', project_feedback[0])
        self.assertIn('expert_uri', project_feedback[0])

        # test that multiple feedback cannont be submitted without a revision
        #self.assertFalse(project_api.ready_for_feedback(project['uri']))
        #with self.assertRaises(Exception):
        #    project_api.submit_feedback(project['uri'], '/uri/user/badgemaker', 'Ugly', 'Bad', 'Good')

        project_api.revise_project(project['uri'], 'everything is better now!!')
        project_feedback = project_api.get_project_feedback(project['uri'])
        self.assertEqual(len(project_feedback), 2)

        project_api.submit_feedback(project['uri'], '/uri/user/badgemaker', 'Ugly', 'Bad', 'Good')

        project_api.revise_project(project['uri'], 'everything is better now, promise!!', work_url='http://mywork.com/new-and-improved')
        project_feedback = project_api.get_project_feedback(project['uri'])
        self.assertEqual(len(project_feedback), 4)
 
        self.assertIn('improvement', project_feedback[1]) 
        self.assertIn('date_created', project_feedback[1]) 
        self.assertNotIn('work_url', project_feedback[1])

        self.assertIn('improvement', project_feedback[3]) 
        self.assertIn('work_url', project_feedback[3])
Exemplo n.º 3
0
    def test_final_feedback(self):
        badge = badge_api.create_badge(**self.badge_values)
        badge_api.publish_badge(badge['uri'])
        user = p2pu_user_api.save_user('badgemaker', 'http://placeholdit.com/40x40', '*****@*****.**')

        project_values = self.project_values.copy()
        project_values['badge_uri'] = badge['uri']
        project = project_api.create_project(**project_values)

        project_feedback = project_api.get_project_feedback(project['uri'])
        self.assertEqual(len(project_feedback), 0)
        
        self.assertTrue(project_api.ready_for_feedback(project['uri']))
        project_api.submit_feedback(project['uri'], badge['author_uri'], 'Ugly', 'Bad', 'Good', True)
        project_feedback = project_api.get_project_feedback(project['uri'])
        self.assertEqual(len(project_feedback), 1)

        self.assertFalse(project_api.ready_for_feedback(project['uri']))
        self.assertFalse(project_api.can_revise_project(project['uri']))