diff options
author | NavaL <mnandri@thoughtworks.com> | 2016-01-18 18:36:07 +0100 |
---|---|---|
committer | NavaL <mnandri@thoughtworks.com> | 2016-01-18 18:36:07 +0100 |
commit | dfd5897b632f846f64b57108895fbbbe1a817290 (patch) | |
tree | c0f648a95842d3679ae56bda0cecb17b3aaf4ef9 /service/pixelated | |
parent | 66a47fa2345775037b127c295f8611534527fadc (diff) |
migrating feedback resources to use services factory
Issue #576
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/resources/__init__.py | 3 | ||||
-rw-r--r-- | service/pixelated/resources/feedback_resource.py | 13 | ||||
-rw-r--r-- | service/pixelated/resources/mail_resource.py | 8 | ||||
-rw-r--r-- | service/pixelated/resources/root_resource.py | 2 |
4 files changed, 15 insertions, 11 deletions
diff --git a/service/pixelated/resources/__init__.py b/service/pixelated/resources/__init__.py index c5ec02f0..3d81d784 100644 --- a/service/pixelated/resources/__init__.py +++ b/service/pixelated/resources/__init__.py @@ -69,3 +69,6 @@ class BaseResource(Resource): def draft_service(self, request): return self._service(request, 'draft_service') + + def feedback_service(self, request): + return self._service(request, 'feedback_service') diff --git a/service/pixelated/resources/feedback_resource.py b/service/pixelated/resources/feedback_resource.py index b989b273..aeead401 100644 --- a/service/pixelated/resources/feedback_resource.py +++ b/service/pixelated/resources/feedback_resource.py @@ -15,18 +15,17 @@ # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. import json -from twisted.web.resource import Resource -from pixelated.resources import respond_json +from pixelated.resources import respond_json, BaseResource -class FeedbackResource(Resource): +class FeedbackResource(BaseResource): isLeaf = True - def __init__(self, feedback_service): - Resource.__init__(self) - self.feedback_service = feedback_service + def __init__(self, services_factory): + BaseResource.__init__(self, services_factory) def render_POST(self, request): + _feedback_service = self.feedback_service(request) feedback = json.loads(request.content.read()).get('feedback') - self.feedback_service.open_ticket(feedback) + _feedback_service.open_ticket(feedback) return respond_json({}, request) diff --git a/service/pixelated/resources/mail_resource.py b/service/pixelated/resources/mail_resource.py index 3661be9d..37fceb9b 100644 --- a/service/pixelated/resources/mail_resource.py +++ b/service/pixelated/resources/mail_resource.py @@ -1,9 +1,11 @@ import json -from pixelated.resources import respond_json, respond_json_deferred, BaseResource -from pixelated.support import replier + +from twisted.python.log import err from twisted.web.resource import Resource from twisted.web.server import NOT_DONE_YET -from twisted.python.log import err + +from pixelated.resources import respond_json_deferred, BaseResource +from pixelated.support import replier class MailTags(Resource): diff --git a/service/pixelated/resources/root_resource.py b/service/pixelated/resources/root_resource.py index 93f90ee1..2adde991 100644 --- a/service/pixelated/resources/root_resource.py +++ b/service/pixelated/resources/root_resource.py @@ -47,7 +47,7 @@ class RootResource(Resource): self.putChild('tags', TagsResource(services_factory)) self.putChild('mails', MailsResource(services_factory)) self.putChild('mail', MailResource(services_factory)) - self.putChild('feedback', FeedbackResource(feedback_service)) + self.putChild('feedback', FeedbackResource(services_factory)) self.putChild('user-settings', UserSettingsResource(self.account_email)) self._mode = MODE_RUNNING |