Exemple #1
0
 def get_scores(self, pm):
     app = pm.application
     scores = app.get_scores()
     update_dict = {"has_voted": False, "vote_cast": None}
     if not self.request_user:
         scores.update(update_dict)
         return scores
     last_vote = ApplicationScore.last_vote(app, self.request_user)
     if last_vote:
         update_dict["has_voted"] = True
         update_dict["vote_cast"] = last_vote.get_vote_name()
     scores.update(update_dict)
     return scores
 def get_scores(self, pm):
     app = pm.application
     scores = app.get_scores()
     update_dict = {
         "has_voted": False,
         "vote_cast": None}
     if not self.request_user:
         scores.update(update_dict)
         return scores
     last_vote = ApplicationScore.last_vote(app, self.request_user)
     if last_vote:
         update_dict["has_voted"] = True
         update_dict["vote_cast"] = last_vote.get_vote_name()
     scores.update(update_dict)
     return scores
Exemple #3
0
    def get(self, request, provider_uuid, identity_uuid, machine_id):
        """
        Lookup the machine information
        (Lookup using the given provider/identity)
        Update on server (If applicable)
        """
        core_machine = ProviderMachine.objects.filter(
            provider__uuid=provider_uuid, identifier=machine_id)
        if not core_machine:
            return failure_response(
                status.HTTP_400_BAD_REQUEST,
                "Machine id %s does not exist" % machine_id)

        app = core_machine[0].application
        vote = ApplicationScore.last_vote(app, request.user)
        serialized_data = ApplicationScoreSerializer(vote).data
        return Response(serialized_data, status=status.HTTP_200_OK)
Exemple #4
0
    def get(self, request, provider_id, identity_id, machine_id):
        """
        Lookup the machine information
        (Lookup using the given provider/identity)
        Update on server (If applicable)
        """
        core_machine = ProviderMachine.objects.filter(provider__id=provider_id,
                                                      identifier=machine_id)
        if not core_machine:
            return failure_response(
                status.HTTP_400_BAD_REQUEST,
                "Machine id %s does not exist" % machine_id)

        app = core_machine[0].application
        vote = ApplicationScore.last_vote(app, request.user)
        serialized_data = ApplicationScoreSerializer(vote).data
        return Response(serialized_data, status=status.HTTP_201_CREATED)