From 3c6b905d7e5b78e521b2e7692e5e32b7b0c226bc Mon Sep 17 00:00:00 2001 From: Felix Hammerl Date: Mon, 8 Feb 2016 17:54:58 +0100 Subject: Revert "Issue #549 - Implemented remove attachment" This reverts commit 9442be5c230e286073244451189ffc05ae6c8083. --- .../adapter/mailstore/leap_attachment_store.py | 6 ------ service/pixelated/adapter/services/mail_service.py | 10 +++------- service/pixelated/resources/attachments_resource.py | 3 --- .../adapter/mailstore/test_leap_attachment_store.py | 15 --------------- web-ui/app/js/mail_view/ui/attachment_list.js | 20 ++------------------ web-ui/app/js/mail_view/ui/forward_box.js | 5 ++--- 6 files changed, 7 insertions(+), 52 deletions(-) diff --git a/service/pixelated/adapter/mailstore/leap_attachment_store.py b/service/pixelated/adapter/mailstore/leap_attachment_store.py index 2c004abf..982d9222 100644 --- a/service/pixelated/adapter/mailstore/leap_attachment_store.py +++ b/service/pixelated/adapter/mailstore/leap_attachment_store.py @@ -63,9 +63,3 @@ class LeapAttachmentStore(object): def _calc_attachment_id_(self, content, content_type, encoder=encoders.encode_base64): cdoc = self._attachment_to_cdoc(content, content_type, encoder) return cdoc.phash - - @defer.inlineCallbacks - def delete_attachment(self, attachment_id): - doc = yield self.soledad.get_from_index('by-type-and-payloadhash', 'cnt', attachment_id) - doc = doc[0] - yield self.soledad.delete_doc(doc) diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py index 5ec3a298..2da2cca6 100644 --- a/service/pixelated/adapter/services/mail_service.py +++ b/service/pixelated/adapter/services/mail_service.py @@ -35,7 +35,7 @@ class MailService(object): self.search_engine = search_engine self.mail_sender = mail_sender self.account_email = account_email - self.attachment_store = attachment_store + self.attchment_store = attachment_store @defer.inlineCallbacks def all_mails(self): @@ -43,7 +43,7 @@ class MailService(object): defer.returnValue(mails) def save_attachment(self, content, content_type): - return self.attachment_store.add_attachment(content, content_type) + return self.attchment_store.add_attachment(content, content_type) @log_time_deferred @defer.inlineCallbacks @@ -87,7 +87,7 @@ class MailService(object): return self.mail_store.get_mail(mail_id, include_body=True) def attachment(self, attachment_id): - return self.attachment_store.get_mail_attachment(attachment_id) + return self.attchment_store.get_mail_attachment(attachment_id) @defer.inlineCallbacks def mail_exists(self, mail_id): @@ -151,7 +151,3 @@ class MailService(object): @defer.inlineCallbacks def delete_permanent(self, mail_id): yield self.mail_store.delete_mail(mail_id) - - @defer.inlineCallbacks - def delete_attachment(self, attachment_id): - yield self.attachment_store.delete_attachment(attachment_id) diff --git a/service/pixelated/resources/attachments_resource.py b/service/pixelated/resources/attachments_resource.py index 401fb321..249d268a 100644 --- a/service/pixelated/resources/attachments_resource.py +++ b/service/pixelated/resources/attachments_resource.py @@ -71,9 +71,6 @@ class AttachmentResource(Resource): match = re.compile('([A-Za-z-]+\/[A-Za-z-]+)').search(content_type) return match.group(1) - def render_DELETE(self, request): - self.mail_service.delete_attachment(self.attachment_id) - class AttachmentsResource(BaseResource): BASE_URL = 'attachment' diff --git a/service/test/unit/adapter/mailstore/test_leap_attachment_store.py b/service/test/unit/adapter/mailstore/test_leap_attachment_store.py index f1bd8528..4e9b56b1 100644 --- a/service/test/unit/adapter/mailstore/test_leap_attachment_store.py +++ b/service/test/unit/adapter/mailstore/test_leap_attachment_store.py @@ -116,21 +116,6 @@ class TestLeapAttachmentStore(TestCase): except ValueError: pass - @defer.inlineCallbacks - def test_soledad_delete_doc_is_called_when_deleting_an_attachment(self): - attachment_id = '1B0A9AAD9E153D24265395203C53884506ABA276394B9FEC02B214BF9E77E48E' - doc = SoledadDocument(json=json.dumps({'content_type': 'foo/bar', 'raw': 'quoted-printable', - 'phash': attachment_id, - 'content_transfer_encoding': ''})) - - when(self.soledad).get_from_index('by-type-and-payloadhash', 'cnt', attachment_id).thenReturn(defer.succeed([doc])) - when(self.soledad).delete_doc(doc).thenReturn(defer.succeed(None)) - - store = LeapAttachmentStore(self.soledad) - yield store.delete_attachment(attachment_id) - - verify(self.soledad).delete_doc(doc) - def _mock_get_mailbox(self, mailbox_name, create_new_uuid=False): mbox_uuid = self.mbox_uuid if not create_new_uuid else str(uuid4()) when(self.soledad).list_indexes().thenReturn(defer.succeed(MAIL_INDEXES)).thenReturn( diff --git a/web-ui/app/js/mail_view/ui/attachment_list.js b/web-ui/app/js/mail_view/ui/attachment_list.js index 3d57ede5..b3b26710 100644 --- a/web-ui/app/js/mail_view/ui/attachment_list.js +++ b/web-ui/app/js/mail_view/ui/attachment_list.js @@ -19,11 +19,10 @@ define( [ 'views/templates', 'page/events', - 'helpers/view_helper', - 'helpers/monitored_ajax' + 'helpers/view_helper' ], - function (templates, events, viewHelper, monitoredAjax) { + function (templates, events, viewHelper) { 'use strict'; function attachmentList() { @@ -181,26 +180,11 @@ define( this.select('inputFileUpload').click(); }; - this.removeAttachments = function(event, data) { - var success = function() { - console.log('Success'); - }; - - var failure = function() { - console.log('Fail!!!!!'); - }; - - monitoredAjax(this, '/attachment/' + data.ident, { - type: 'DELETE' - }).done(success.bind(this)).fail(failure.bind(this)); - }; - this.after('initialize', function () { this.addJqueryFileUploadConfig(); this.on(document, events.mail.uploadedAttachment, this.showAttachment); this.on(document, events.mail.startUploadAttachment, this.startUpload); this.on(document, events.mail.appendAttachment, this.addAttachment); - this.on(document, events.mail.removeAttachment, this.removeAttachments); }); } diff --git a/web-ui/app/js/mail_view/ui/forward_box.js b/web-ui/app/js/mail_view/ui/forward_box.js index 5acef337..3d643b2f 100644 --- a/web-ui/app/js/mail_view/ui/forward_box.js +++ b/web-ui/app/js/mail_view/ui/forward_box.js @@ -56,7 +56,7 @@ define( self.trigger(document, events.mail.removeAttachment, {ident: ident}); event.preventDefault(); }); - + this.on(this.select('subjectDisplay'), 'click', this.showSubjectInput); this.select('recipientsDisplay').hide(); this.select('recipientsFields').show(); @@ -64,8 +64,7 @@ define( this.convertToRemovableAttachments = function(attachments) { return attachments.map(function(attachment) { - attachment.removable = false; // don't show this button until the bug is fixed - attachment.received = true; + attachment.removable = true; return attachment; }); }; -- cgit v1.2.3