Add api_action class attribute so that disable sender and verify sender can use the same view.

This commit is contained in:
Chris Jones
2012-01-16 17:03:51 -08:00
parent 799f9ba7fd
commit 8141037bf4
2 changed files with 14 additions and 3 deletions

View File

@@ -63,7 +63,8 @@ class DjrillSendersListView(DjrillApiMixin, DjrillApiJsonObjectsMixin,
return self.render_to_response({"objects": json.loads(objects)})
class DjrillDisableSenderView(DjrillApiMixin, View):
class DjrillSenderView(DjrillApiMixin, View):
api_action = None
def post(self, request):
email = request.POST.get("email", None)
@@ -73,10 +74,18 @@ class DjrillDisableSenderView(DjrillApiMixin, View):
"key": self.api_key,
"email": email
}
req = requests.post("%s/users/disable-sender.json" % self.api_url,
req = requests.post("%s/%s" % (self.api_url, self.api_action),
data=json.dumps(payload))
if req.status_code == 200:
return HttpResponse("success")
return HttpResponseForbidden()
class DjrillDisableSenderView(DjrillSenderView):
api_action = "users/disable-sender.json"
class DjrillVerifySenderView(DjrillSenderView):
api_action = "users/verify-sender.json"