def post(self, request, command):
        with self._handle_exception(request):
            if (command == 'activate-stable'):
                password = request.data.get('activation_code', None)
                if (password is None):
                    e_msg = (
                        'Activation code is required for Stable subscription')
                    handle_exception(Exception(e_msg), request)
                #remove any leading or trailing white spaces. happens enough times
                #due to copy-paste.
                password = password.strip()
                stableo = self._toggle_repos(password=password)
                return Response(UpdateSubscriptionSerializer(stableo).data)

            if (command == 'activate-testing'):
                testingo = self._toggle_repos(on='testing', off='stable')
                return Response(UpdateSubscriptionSerializer(testingo).data)

            if (command == 'check-status'):
                name = request.data.get('name')
                stableo = UpdateSubscription.objects.get(name=name)
                if (stableo.password is not None):
                    stableo.status, text = repo_status(stableo)
                    stableo.save()
                return Response(UpdateSubscriptionSerializer(stableo).data)
예제 #2
0
    def post(self, request, command):
        with self._handle_exception(request):
            if command == "activate-stable":
                password = request.data.get("activation_code", None)
                if password is None:
                    e_msg = "Activation code is required for Stable subscription."
                    handle_exception(Exception(e_msg),
                                     request,
                                     status_code=400)
                # remove any leading or trailing white spaces. happens enough
                # times due to copy-paste.
                password = password.strip()
                stableo = self._toggle_repos(password=password)
                return Response(UpdateSubscriptionSerializer(stableo).data)

            if command == "activate-testing":
                testingo = self._toggle_repos(on="testing", off="stable")
                return Response(UpdateSubscriptionSerializer(testingo).data)

            if command == "check-status":
                name = request.data.get("name")
                stableo = UpdateSubscription.objects.get(name=name)
                if stableo.password is not None:
                    stableo.status, text = repo_status(stableo)
                    stableo.save()
                return Response(UpdateSubscriptionSerializer(stableo).data)