summaryrefslogtreecommitdiff
path: root/service/pixelated/config
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-11-20 13:43:12 -0200
committerDuda Dornelles <ddornell@thoughtworks.com>2014-11-24 08:21:59 -0200
commit4f484e4dd2a40c4b3c71cd3d241785fb3a7b2eaf (patch)
tree09d494d82ac812e87e45c1b1ccc6ff2693b49a62 /service/pixelated/config
parentd4b29e22f51c986e4b8306f1782ef3603248d0d5 (diff)
Adding contacts controller and basic contact search
Diffstat (limited to 'service/pixelated/config')
-rw-r--r--service/pixelated/config/app_factory.py32
-rw-r--r--service/pixelated/config/routes.py26
2 files changed, 30 insertions, 28 deletions
diff --git a/service/pixelated/config/app_factory.py b/service/pixelated/config/app_factory.py
index 497ab205..eb31a271 100644
--- a/service/pixelated/config/app_factory.py
+++ b/service/pixelated/config/app_factory.py
@@ -16,6 +16,7 @@
import sys
from twisted.internet import reactor
+from pixelated.config.routes import setup_routes
from pixelated.adapter.mail_service import MailService
from pixelated.adapter.mail import InputMail
from pixelated.adapter.mail_sender import MailSender
@@ -57,32 +58,6 @@ def update_info_sync_and_index_partial(sync_info_controller, search_engine, mail
return wrapper
-def _setup_routes(app, home_controller, mails_controller, tags_controller, features_controller, sync_info_controller,
- attachments_controller):
- # mails
- app.route('/mails', methods=['GET'])(mails_controller.mails)
- app.route('/mail/<mail_id>/read', methods=['POST'])(mails_controller.mark_mail_as_read)
- app.route('/mail/<mail_id>/unread', methods=['POST'])(mails_controller.mark_mail_as_unread)
- app.route('/mails/unread', methods=['POST'])(mails_controller.mark_many_mail_unread)
- app.route('/mails/read', methods=['POST'])(mails_controller.mark_many_mail_read)
- app.route('/mail/<mail_id>', methods=['GET'])(mails_controller.mail)
- app.route('/mail/<mail_id>', methods=['DELETE'])(mails_controller.delete_mail)
- app.route('/mails', methods=['DELETE'])(mails_controller.delete_mails)
- app.route('/mails', methods=['POST'])(mails_controller.send_mail)
- app.route('/mail/<mail_id>/tags', methods=['POST'])(mails_controller.mail_tags)
- app.route('/mails', methods=['PUT'])(mails_controller.update_draft)
- # tags
- app.route('/tags', methods=['GET'])(tags_controller.tags)
- # features
- app.route('/features', methods=['GET'])(features_controller.features)
- # sync info
- app.route('/sync_info', methods=['GET'])(sync_info_controller.sync_info)
- # attachments
- app.route('/attachment/<attachment_id>', methods=['GET'])(attachments_controller.attachment)
- # static
- app.route('/', methods=['GET'], branch=True)(home_controller.home)
-
-
def init_leap_session(app):
try:
leap_session = LeapSession.open(app.config['LEAP_USERNAME'],
@@ -126,6 +101,7 @@ def init_app(app):
draft_service=draft_service,
search_engine=search_engine)
tags_controller = TagsController(search_engine=search_engine)
+ contacts_controller = ContactsController(search_engine=search_engine)
sync_info_controller = SyncInfoController()
attachments_controller = AttachmentsController(soledad_querier)
@@ -141,8 +117,8 @@ def init_app(app):
register(signal=proto.SOLEDAD_DONE_DATA_SYNC, uid=CREATE_KEYS_IF_KEYS_DONT_EXISTS_CALLBACK,
callback=look_for_user_key_and_create_if_cant_find(leap_session))
- _setup_routes(app, home_controller, mails_controller, tags_controller, features_controller,
- sync_info_controller, attachments_controller)
+ setup_routes(app, home_controller, mails_controller, tags_controller, features_controller,
+ sync_info_controller, attachments_controller, contacts_controller)
def create_app(app, bind_address, bind_port):
diff --git a/service/pixelated/config/routes.py b/service/pixelated/config/routes.py
new file mode 100644
index 00000000..6bad8a17
--- /dev/null
+++ b/service/pixelated/config/routes.py
@@ -0,0 +1,26 @@
+def setup_routes(app, home_controller, mails_controller, tags_controller, features_controller, sync_info_controller,
+ attachments_controller, contacts_controller):
+ # mails
+ app.route('/mails', methods=['GET'])(mails_controller.mails)
+ app.route('/mail/<mail_id>/read', methods=['POST'])(mails_controller.mark_mail_as_read)
+ app.route('/mail/<mail_id>/unread', methods=['POST'])(mails_controller.mark_mail_as_unread)
+ app.route('/mails/unread', methods=['POST'])(mails_controller.mark_many_mail_unread)
+ app.route('/mails/read', methods=['POST'])(mails_controller.mark_many_mail_read)
+ app.route('/mail/<mail_id>', methods=['GET'])(mails_controller.mail)
+ app.route('/mail/<mail_id>', methods=['DELETE'])(mails_controller.delete_mail)
+ app.route('/mails', methods=['DELETE'])(mails_controller.delete_mails)
+ app.route('/mails', methods=['POST'])(mails_controller.send_mail)
+ app.route('/mail/<mail_id>/tags', methods=['POST'])(mails_controller.mail_tags)
+ app.route('/mails', methods=['PUT'])(mails_controller.update_draft)
+ # tags
+ app.route('/tags', methods=['GET'])(tags_controller.tags)
+ # contacts
+ app.route('/contacts', methods=['GET'])(contacts_controller.contacts)
+ # features
+ app.route('/features', methods=['GET'])(features_controller.features)
+ # sync info
+ app.route('/sync_info', methods=['GET'])(sync_info_controller.sync_info)
+ # attachments
+ app.route('/attachment/<attachment_id>', methods=['GET'])(attachments_controller.attachment)
+ # static
+ app.route('/', methods=['GET'], branch=True)(home_controller.home) \ No newline at end of file