From 4480fa7de1b503b83a510e3a6aaba5bb4e40f0ce Mon Sep 17 00:00:00 2001 From: Markos Gogoulos Date: Mon, 27 Sep 2021 15:07:17 +0300 Subject: [PATCH] documentation, admin section, plus fix of a typo on models (#293) * documentation, admin section, plus fix of a typo on models --- docs/admins_docs.md | 36 +++++++++++++++++++++ files/migrations/0003_auto_20210927_1245.py | 18 +++++++++++ files/models.py | 2 +- tests/api/test_new_media.py | 11 ++++++- 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 files/migrations/0003_auto_20210927_1245.py diff --git a/docs/admins_docs.md b/docs/admins_docs.md index f3b5328..a3d6ad9 100644 --- a/docs/admins_docs.md +++ b/docs/admins_docs.md @@ -15,6 +15,7 @@ - [12. Video transcoding](#12-video-transcoding) - [13. How To Add A Static Page To The Sidebar](#13-how-to-add-a-static-page-to-the-sidebar) - [14. Add Google Analytics](#14-add-google-analytics) +- [15. Debugging email issues](#15-debugging-email-issues) ## 1. Welcome @@ -648,3 +649,38 @@ Instructions contributed by @alberto98fx - ./templates/tracking.html://home/mediacms.io/mediacms/templates/tracking.html ``` + +## 15. Debugging email issues +On the [Configuration](https://github.com/mediacms-io/mediacms/blob/main/docs/admins_docs.md#5-configuration) section of this guide we've see how to edit the email settings. +In case we are yet unable to receive email from MediaCMS, the following may help us debug the issue - in most cases it is an issue of setting the correct username, password or TLS option + +Enter the Django shell, example if you're using the Single Server installation: + +```bash +source /home/mediacms.io/bin/activate +python manage.py shell +``` + +and inside the shell + +```bash +from django.core.mail import EmailMessage +from django.conf import settings + +settings.EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' + +email = EmailMessage( + 'title', + 'msg', + settings.DEFAULT_FROM_EMAIL, + ['recipient@email.com'], +) +email.send(fail_silently=False) +``` + +You have the chance to either receive the email (in this case it will be sent to recipient@email.com) otherwise you will see the error. +For example, while specifying wrong password for my Gmail account I get + +``` +SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials d4sm12687785wrc.34 - gsmtp') +``` \ No newline at end of file diff --git a/files/migrations/0003_auto_20210927_1245.py b/files/migrations/0003_auto_20210927_1245.py new file mode 100644 index 0000000..d0fd13c --- /dev/null +++ b/files/migrations/0003_auto_20210927_1245.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.12 on 2021-09-27 11:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('files', '0002_auto_20201201_0712'), + ] + + operations = [ + migrations.AlterField( + model_name='media', + name='reported_times', + field=models.IntegerField(default=0, help_text='how many time a media is reported'), + ), + ] diff --git a/files/models.py b/files/models.py index 3339d4d..e406d24 100644 --- a/files/models.py +++ b/files/models.py @@ -209,7 +209,7 @@ class Media(models.Model): help_text="Rating category, if media Rating is allowed", ) - reported_times = models.IntegerField(default=0, help_text="how many time a Medis is reported") + reported_times = models.IntegerField(default=0, help_text="how many time a media is reported") search = SearchVectorField( null=True, diff --git a/tests/api/test_new_media.py b/tests/api/test_new_media.py index c01bedd..45e6f40 100644 --- a/tests/api/test_new_media.py +++ b/tests/api/test_new_media.py @@ -20,7 +20,11 @@ class TestX(TestCase): client.login(username=self.user, password=self.password) # use both ways, form + API to upload a new media file - # ffmpeg will transcode files synchronously + # while video transcoding through ffmpeg takes place asynchronously + # (through celery workers), inside tests ffmpeg runs synchronously + # because celery is started with setting task_always_eager + # practically this means that this testing will take some time, but + # ensures that video transcoding completes well with open('fixtures/small_video.mp4', 'rb') as fp: client.post('/api/v1/media', {'title': 'small video file test', 'media_file': fp}) @@ -31,9 +35,14 @@ class TestX(TestCase): client.post('/fu/upload/', {'qqfile': fp, 'qqfilename': 'medium_video.mp4', 'qquuid': str(uuid.uuid4())}) self.assertEqual(Media.objects.all().count(), 3, "Problem with file upload") + + # by default the portal_workflow is public, so anything uploaded gets public self.assertEqual(Media.objects.filter(state='public').count(), 3, "Expected all media to be public, as per the default portal workflow") self.assertEqual(Media.objects.filter(media_type='video', encoding_status='success').count(), 2, "Encoding did not finish well") self.assertEqual(Media.objects.filter(media_type='video').count(), 2, "Media identification failed") self.assertEqual(Media.objects.filter(media_type='image').count(), 1, "Media identification failed") self.assertEqual(Media.objects.filter(user=self.user).count(), 3, "User assignment failed") + + # using the provided EncodeProfiles, these two files should produce 9 Encoding objects. + # if new EncodeProfiles are added and enabled, this will break! self.assertEqual(Encoding.objects.filter(status='success').count(), 9, "Not all video transcodings finished well")