-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reviewer Tools Pastebin Re-implementation (#22640)
* Added pastebin reimplementation on reviewer tools side * make lint * Moved attachment upload box to own section (and available for all actions) * Fixed css for textareas, returned datetime-wrapper * Missing assignment * Updated naming for files, limited to .txt and .zip, temporarily updated query number assertion * added waffle enable-activity-log-attachments for user facing menus; * testing * corrected test * Removed zip allowance * migration conflict * test (temp) * import * remove git_extraction.py from pr * ??? * numQueries * review changes * lint * prettier * review changes * lol lint * review comment
- Loading branch information
1 parent
6744fdc
commit c6026f6
Showing
22 changed files
with
416 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.urls import re_path | ||
|
||
from . import views | ||
|
||
|
||
urlpatterns = [ | ||
re_path(r'^mail/', views.inbound_email, name='inbound-email-api'), | ||
] |
37 changes: 37 additions & 0 deletions
37
src/olympia/activity/migrations/0026_alter_activitylog_action_attachmentlog.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Generated by Django 4.2.15 on 2024-09-04 15:46 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
import olympia.activity.models | ||
import olympia.amo.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('activity', '0025_alter_activitylog_action_cinderpolicylog'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='activitylog', | ||
name='action', | ||
field=models.SmallIntegerField(choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (12, 12), (16, 16), (17, 17), (18, 18), (19, 19), (20, 20), (21, 21), (22, 22), (23, 23), (24, 24), (25, 25), (26, 26), (27, 27), (28, 28), (29, 29), (31, 31), (32, 32), (33, 33), (34, 34), (35, 35), (36, 36), (37, 37), (38, 38), (39, 39), (40, 40), (41, 41), (42, 42), (43, 43), (44, 44), (45, 45), (46, 46), (47, 47), (48, 48), (49, 49), (53, 53), (60, 60), (61, 61), (62, 62), (98, 98), (99, 99), (100, 100), (101, 101), (102, 102), (103, 103), (104, 104), (105, 105), (106, 106), (107, 107), (108, 108), (109, 109), (110, 110), (120, 120), (121, 121), (128, 128), (130, 130), (131, 131), (132, 132), (133, 133), (134, 134), (135, 135), (136, 136), (137, 137), (138, 138), (139, 139), (140, 140), (141, 141), (142, 142), (143, 143), (144, 144), (145, 145), (146, 146), (147, 147), (148, 148), (149, 149), (150, 150), (151, 151), (152, 152), (153, 153), (154, 154), (155, 155), (156, 156), (157, 157), (158, 158), (159, 159), (160, 160), (161, 161), (162, 162), (163, 163), (164, 164), (165, 165), (166, 166), (167, 167), (168, 168), (169, 169), (170, 170), (171, 171), (172, 172), (173, 173), (174, 174), (175, 175), (176, 176), (177, 177), (178, 178), (179, 179), (180, 180), (181, 181), (182, 182), (183, 183), (184, 184), (185, 185), (186, 186), (187, 187), (188, 188), (189, 189), (190, 190), (191, 191), (192, 192)]), | ||
), | ||
migrations.CreateModel( | ||
name='AttachmentLog', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created', models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False)), | ||
('modified', models.DateTimeField(auto_now=True)), | ||
('file', models.FileField(blank=True, null=True, storage=olympia.activity.models.activity_attachment_storage, upload_to=olympia.activity.models.attachment_upload_path)), | ||
('activity_log', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='activity.activitylog')), | ||
], | ||
options={ | ||
'db_table': 'log_activity_attachment', | ||
'ordering': ('-created',), | ||
}, | ||
bases=(olympia.amo.models.SaveUpdateMixin, models.Model), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,19 @@ | |
from unittest import mock | ||
|
||
from django.conf import settings | ||
from django.core.files.base import ContentFile | ||
from django.test.utils import override_settings | ||
|
||
from rest_framework.exceptions import ErrorDetail | ||
from rest_framework.test import APIRequestFactory | ||
|
||
from olympia import amo | ||
from olympia.activity.models import GENERIC_USER_NAME, ActivityLog, ActivityLogToken | ||
from olympia.activity.models import ( | ||
GENERIC_USER_NAME, | ||
ActivityLog, | ||
ActivityLogToken, | ||
AttachmentLog, | ||
) | ||
from olympia.activity.tests.test_serializers import LogMixin | ||
from olympia.activity.tests.test_utils import sample_message_content | ||
from olympia.activity.views import InboundEmailIPPermission, inbound_email | ||
|
@@ -20,6 +26,7 @@ | |
AddonUser, | ||
) | ||
from olympia.addons.utils import generate_addon_guid | ||
from olympia.amo.reverse import reverse | ||
from olympia.amo.tests import ( | ||
APITestClientSessionID, | ||
TestCase, | ||
|
@@ -660,3 +667,33 @@ def test_validation_response_wrong_secret(self, _mock): | |
res = inbound_email(req) | ||
assert not _mock.called | ||
assert res.status_code == 403 | ||
|
||
|
||
class TestDownloadAttachment(TestCase): | ||
def setUp(self): | ||
super().setUp() | ||
self.addon = addon_factory( | ||
guid=generate_addon_guid(), name='My Addôn', slug='my-addon' | ||
) | ||
self.user = user_factory(email='[email protected]') | ||
self.log = ActivityLog.objects.create( | ||
user=self.user, action=amo.LOG.REVIEWER_REPLY_VERSION | ||
) | ||
self.attachment = AttachmentLog.objects.create( | ||
activity_log=self.log, | ||
file=ContentFile('Pseudo File', name='attachment.txt'), | ||
) | ||
|
||
def test_download_attachment_success(self): | ||
self.client.force_login(self.user) | ||
self.grant_permission(self.user, 'Addons:Review', 'Addon Reviewers') | ||
url = reverse('activity.attachment', args=[self.log.pk]) | ||
response = self.client.get(url, follow=True) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertIn('.txt', response['Content-Disposition']) | ||
|
||
def test_download_attachment_failure(self): | ||
self.client.force_login(self.user) | ||
url = reverse('activity.attachment', args=[self.log.pk]) | ||
response = self.client.get(url, follow=True) | ||
self.assertEqual(response.status_code, 404) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/olympia/reviewers/migrations/0038_auto_20240909_1647.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Generated by Django 4.2.15 on 2024-09-09 16:47 | ||
|
||
from django.db import migrations | ||
|
||
from olympia.core.db.migrations import CreateWaffleSwitch | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('reviewers', '0037_autoapprovalsummary_is_pending_rejection'), | ||
] | ||
|
||
operations = [ | ||
CreateWaffleSwitch('enable-activity-log-attachments') | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.