mirror of
https://github.com/mediacms-io/mediacms.git
synced 2024-11-21 15:53:21 +01:00
parent
748d4bae4b
commit
7bda0acd8b
@ -433,7 +433,7 @@ GLOBAL_LOGIN_REQUIRED = False
|
||||
|
||||
try:
|
||||
# keep a local_settings.py file for local overrides
|
||||
from .local_settings import *
|
||||
from .local_settings import * # noqa
|
||||
|
||||
# ALLOWED_HOSTS needs a url/ip
|
||||
ALLOWED_HOSTS.append(FRONTEND_HOST.replace("http://", "").replace("https://", ""))
|
||||
|
@ -1,12 +1,11 @@
|
||||
from django.conf import settings
|
||||
from django.contrib.postgres.search import SearchQuery
|
||||
from django.contrib.syndication.views import Feed
|
||||
from django.db.models import Q
|
||||
from django.urls import reverse
|
||||
from django.utils.feedgenerator import Rss201rev2Feed
|
||||
|
||||
from . import helpers
|
||||
from .models import Category, Media
|
||||
from .models import Media
|
||||
from .stop_words import STOP_WORDS
|
||||
|
||||
|
||||
|
@ -381,7 +381,6 @@ def media_file_info(input_file):
|
||||
}
|
||||
|
||||
if has_audio:
|
||||
audio_duration = 1
|
||||
if "duration" in audio_info.keys():
|
||||
audio_duration = float(audio_info["duration"])
|
||||
elif "tags" in audio_info.keys() and "DURATION" in audio_info["tags"]:
|
||||
|
@ -24,7 +24,6 @@ from imagekit.processors import ResizeToFit
|
||||
from mptt.models import MPTTModel, TreeForeignKey
|
||||
|
||||
from . import helpers
|
||||
from .methods import notify_users
|
||||
from .stop_words import STOP_WORDS
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -1343,6 +1342,8 @@ def media_save(sender, instance, created, **kwargs):
|
||||
# SOS: do not put anything here, as if more logic is added,
|
||||
# we have to disconnect signal to avoid infinite recursion
|
||||
if created:
|
||||
from .methods import notify_users
|
||||
|
||||
instance.media_init()
|
||||
notify_users(friendly_token=instance.friendly_token, action="media_added")
|
||||
|
||||
@ -1507,7 +1508,7 @@ def encoding_file_save(sender, instance, created, **kwargs):
|
||||
# to avoid that this is run twice
|
||||
if (
|
||||
len(orig_chunks)
|
||||
== Encoding.objects.filter(
|
||||
== Encoding.objects.filter( # noqa
|
||||
media=instance.media,
|
||||
profile=instance.profile,
|
||||
chunks_info=instance.chunks_info,
|
||||
@ -1537,7 +1538,7 @@ def encoding_file_save(sender, instance, created, **kwargs):
|
||||
chunks_paths = [f.media_file.path for f in chunks]
|
||||
|
||||
all_logs = "\n".join([st.logs for st in chunks])
|
||||
encoding.logs = "{0}\n{1}\n{2}".format(chunks_paths, all_logs)
|
||||
encoding.logs = "{0}\n{1}".format(chunks_paths, all_logs)
|
||||
workers = list(set([st.worker for st in chunks]))
|
||||
encoding.worker = json.dumps({"workers": workers})
|
||||
start_date = min([st.add_date for st in chunks])
|
||||
@ -1548,7 +1549,7 @@ def encoding_file_save(sender, instance, created, **kwargs):
|
||||
who = Encoding.objects.filter(media=encoding.media, profile=encoding.profile).exclude(id=encoding.id)
|
||||
|
||||
who.delete()
|
||||
pass # TODO: merge with above if, do not repeat code
|
||||
# TODO: merge with above if, do not repeat code
|
||||
else:
|
||||
if instance.status in ["fail", "success"]:
|
||||
instance.media.post_encode_actions(encoding=instance, action="add")
|
||||
@ -1556,7 +1557,6 @@ def encoding_file_save(sender, instance, created, **kwargs):
|
||||
encodings = set([encoding.status for encoding in Encoding.objects.filter(media=instance.media)])
|
||||
if ("running" in encodings) or ("pending" in encodings):
|
||||
return
|
||||
workers = list(set([encoding.worker for encoding in Encoding.objects.filter(media=instance.media)]))
|
||||
|
||||
|
||||
@receiver(post_delete, sender=Encoding)
|
||||
|
@ -795,7 +795,7 @@ class MediaSearch(APIView):
|
||||
media = media.filter(user__username=author)
|
||||
|
||||
if upload_date:
|
||||
gte = lte = None
|
||||
gte = None
|
||||
if upload_date == 'today':
|
||||
gte = datetime.now().date()
|
||||
if upload_date == 'this_week':
|
||||
@ -807,8 +807,6 @@ class MediaSearch(APIView):
|
||||
if upload_date == 'this_year':
|
||||
year = datetime.now().date().year
|
||||
gte = datetime(year, 1, 1)
|
||||
if lte:
|
||||
media = media.filter(add_date__lte=lte)
|
||||
if gte:
|
||||
media = media.filter(add_date__gte=gte)
|
||||
|
||||
@ -1046,8 +1044,8 @@ class EncodingDetail(APIView):
|
||||
chunk=chunk,
|
||||
chunk_file_path=chunk_file_path,
|
||||
).count()
|
||||
> 1
|
||||
and force is False
|
||||
> 1 # noqa
|
||||
and force is False # noqa
|
||||
):
|
||||
Encoding.objects.filter(id=encoding_id).delete()
|
||||
return Response({"status": "fail"}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
@ -1,4 +1,5 @@
|
||||
[flake8]
|
||||
exclude = .git,*migrations*
|
||||
max-line-length = 119
|
||||
ignore=F401,F403,E501,W503
|
||||
#ignore=F401,F403,E501,W503
|
||||
ignore=E501
|
||||
|
@ -149,7 +149,6 @@ def contact_user(request, username):
|
||||
)
|
||||
user = User.objects.filter(username=username).first()
|
||||
if user and (user.allow_contact or is_mediacms_editor(request.user)):
|
||||
subject = request.data.get("subject")
|
||||
from_email = request.user.email
|
||||
subject = f"[{settings.PORTAL_NAME}] - Message from {from_email}"
|
||||
body = request.data.get("body")
|
||||
|
Loading…
Reference in New Issue
Block a user