Event edit button

merge-requests/8/head
Bob Mottram 2020-08-26 18:41:38 +01:00
parent 3b7bc19dba
commit dcefa585bb
18 changed files with 85 additions and 53 deletions

View File

@ -10,6 +10,7 @@ import json
import os import os
import datetime import datetime
import time import time
from utils import isEventPost
from utils import removeIdEnding from utils import removeIdEnding
from utils import getProtocolPrefixes from utils import getProtocolPrefixes
from utils import isBlogPost from utils import isBlogPost
@ -774,43 +775,6 @@ def receiveUndo(session, baseDir: str, httpPrefix: str,
return False return False
def isEventPost(messageJson: {}) -> bool:
"""Is the given post a mobilizon-type event activity?
See https://framagit.org/framasoft/mobilizon/-/blob/
master/lib/federation/activity_stream/converter/event.ex
"""
if not messageJson.get('id'):
return False
if not messageJson.get('actor'):
return False
if not messageJson.get('object'):
return False
if not isinstance(messageJson['object'], dict):
return False
if not messageJson['object'].get('type'):
return False
if messageJson['object']['type'] != 'Event':
return False
print('Event arriving')
if not messageJson['object'].get('startTime'):
print('No event start time')
return False
if not messageJson['object'].get('actor'):
print('No event actor')
return False
if not messageJson['object'].get('content'):
print('No event content')
return False
if not messageJson['object'].get('name'):
print('No event name')
return False
if not messageJson['object'].get('uuid'):
print('No event UUID')
return False
print('Event detected')
return True
def receiveEventPost(recentPostsCache: {}, session, baseDir: str, def receiveEventPost(recentPostsCache: {}, session, baseDir: str,
httpPrefix: str, domain: str, port: int, httpPrefix: str, domain: str, port: int,
sendThreads: [], postLog: [], cachedWebfingers: {}, sendThreads: [], postLog: [], cachedWebfingers: {},

View File

@ -280,5 +280,6 @@
"Maximum attendees": "الحد الأقصى للحضور", "Maximum attendees": "الحد الأقصى للحضور",
"Ticket URL": "عنوان URL للتذكرة", "Ticket URL": "عنوان URL للتذكرة",
"Create a new event": "أنشئ حدثًا جديدًا", "Create a new event": "أنشئ حدثًا جديدًا",
"Moderation policy or code of conduct": "سياسة الوسطية أو قواعد السلوك" "Moderation policy or code of conduct": "سياسة الوسطية أو قواعد السلوك",
"Edit event": "تحرير الحدث"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "Màxim dassistents", "Maximum attendees": "Màxim dassistents",
"Ticket URL": "URL de l'entrada", "Ticket URL": "URL de l'entrada",
"Create a new event": "Creeu un esdeveniment nou", "Create a new event": "Creeu un esdeveniment nou",
"Moderation policy or code of conduct": "Política de moderació o codi de conducta" "Moderation policy or code of conduct": "Política de moderació o codi de conducta",
"Edit event": "Edita lesdeveniment"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "Uchafswm mynychwyr", "Maximum attendees": "Uchafswm mynychwyr",
"Ticket URL": "URL y tocyn", "Ticket URL": "URL y tocyn",
"Create a new event": "Creu digwyddiad newydd", "Create a new event": "Creu digwyddiad newydd",
"Moderation policy or code of conduct": "Polisi cymedroli neu god ymddygiad" "Moderation policy or code of conduct": "Polisi cymedroli neu god ymddygiad",
"Edit event": "Golygu digwyddiad"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "Maximale Teilnehmerzahl", "Maximum attendees": "Maximale Teilnehmerzahl",
"Ticket URL": "Ticket URL", "Ticket URL": "Ticket URL",
"Create a new event": "Erstellen Sie ein neues Ereignis", "Create a new event": "Erstellen Sie ein neues Ereignis",
"Moderation policy or code of conduct": "Moderationsrichtlinie oder Verhaltenskodex" "Moderation policy or code of conduct": "Moderationsrichtlinie oder Verhaltenskodex",
"Edit event": "Ereignis bearbeiten"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "Maximum attendees", "Maximum attendees": "Maximum attendees",
"Ticket URL": "Ticket URL", "Ticket URL": "Ticket URL",
"Create a new event": "Create a new event", "Create a new event": "Create a new event",
"Moderation policy or code of conduct": "Moderation policy or code of conduct" "Moderation policy or code of conduct": "Moderation policy or code of conduct",
"Edit event": "Edit event"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "Asistentes máximos", "Maximum attendees": "Asistentes máximos",
"Ticket URL": "URL del ticket", "Ticket URL": "URL del ticket",
"Create a new event": "Crea un nuevo evento", "Create a new event": "Crea un nuevo evento",
"Moderation policy or code of conduct": "Política de moderación o código de conducta" "Moderation policy or code of conduct": "Política de moderación o código de conducta",
"Edit event": "Editar evento"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "Nombre maximum de participants", "Maximum attendees": "Nombre maximum de participants",
"Ticket URL": "URL du ticket", "Ticket URL": "URL du ticket",
"Create a new event": "Créer un nouvel événement", "Create a new event": "Créer un nouvel événement",
"Moderation policy or code of conduct": "Politique de modération ou code de conduite" "Moderation policy or code of conduct": "Politique de modération ou code de conduite",
"Edit event": "Modifier l'événement"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "Uasmhéid freastail", "Maximum attendees": "Uasmhéid freastail",
"Ticket URL": "URL na dticéad", "Ticket URL": "URL na dticéad",
"Create a new event": "Cruthaigh imeacht nua", "Create a new event": "Cruthaigh imeacht nua",
"Moderation policy or code of conduct": "Beartas modhnóireachta nó cód iompair" "Moderation policy or code of conduct": "Beartas modhnóireachta nó cód iompair",
"Edit event": "Cuir imeacht in eagar"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "अधिकतम उपस्थित", "Maximum attendees": "अधिकतम उपस्थित",
"Ticket URL": "टिकट URL", "Ticket URL": "टिकट URL",
"Create a new event": "एक नई घटना बनाएँ", "Create a new event": "एक नई घटना बनाएँ",
"Moderation policy or code of conduct": "मॉडरेशन पॉलिसी या आचार संहिता" "Moderation policy or code of conduct": "मॉडरेशन पॉलिसी या आचार संहिता",
"Edit event": "घटना संपादित करें"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "Numero massimo di partecipanti", "Maximum attendees": "Numero massimo di partecipanti",
"Ticket URL": "URL del biglietto", "Ticket URL": "URL del biglietto",
"Create a new event": "Crea un nuovo evento", "Create a new event": "Crea un nuovo evento",
"Moderation policy or code of conduct": "Politica di moderazione o codice di condotta" "Moderation policy or code of conduct": "Politica di moderazione o codice di condotta",
"Edit event": "Modifica evento"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "最大参加者", "Maximum attendees": "最大参加者",
"Ticket URL": "チケットURL", "Ticket URL": "チケットURL",
"Create a new event": "新しいイベントを作成する", "Create a new event": "新しいイベントを作成する",
"Moderation policy or code of conduct": "モデレートポリシーまたは行動規範" "Moderation policy or code of conduct": "モデレートポリシーまたは行動規範",
"Edit event": "イベントを編集"
} }

View File

@ -276,5 +276,6 @@
"Maximum attendees": "Maximum attendees", "Maximum attendees": "Maximum attendees",
"Ticket URL": "Ticket URL", "Ticket URL": "Ticket URL",
"Create a new event": "Create a new event", "Create a new event": "Create a new event",
"Moderation policy or code of conduct": "Moderation policy or code of conduct" "Moderation policy or code of conduct": "Moderation policy or code of conduct",
"Edit event": "Edit event"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "Máximo de participantes", "Maximum attendees": "Máximo de participantes",
"Ticket URL": "URL do bilhete", "Ticket URL": "URL do bilhete",
"Create a new event": "Crie um novo evento", "Create a new event": "Crie um novo evento",
"Moderation policy or code of conduct": "Política de moderação ou código de conduta" "Moderation policy or code of conduct": "Política de moderação ou código de conduta",
"Edit event": "Editar evento"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "Максимальное количество участников", "Maximum attendees": "Максимальное количество участников",
"Ticket URL": "URL билета", "Ticket URL": "URL билета",
"Create a new event": "Создать новое мероприятие", "Create a new event": "Создать новое мероприятие",
"Moderation policy or code of conduct": "Политика модерации или кодекс поведения" "Moderation policy or code of conduct": "Политика модерации или кодекс поведения",
"Edit event": "Изменить мероприятие"
} }

View File

@ -280,5 +280,6 @@
"Maximum attendees": "参加人数上限", "Maximum attendees": "参加人数上限",
"Ticket URL": "工单URL", "Ticket URL": "工单URL",
"Create a new event": "建立新活动", "Create a new event": "建立新活动",
"Moderation policy or code of conduct": "审核政策或行为准则" "Moderation policy or code of conduct": "审核政策或行为准则",
"Edit event": "编辑活动"
} }

View File

@ -807,6 +807,43 @@ def mergeDicts(dict1: {}, dict2: {}) -> {}:
return res return res
def isEventPost(messageJson: {}) -> bool:
"""Is the given post a mobilizon-type event activity?
See https://framagit.org/framasoft/mobilizon/-/blob/
master/lib/federation/activity_stream/converter/event.ex
"""
if not messageJson.get('id'):
return False
if not messageJson.get('actor'):
return False
if not messageJson.get('object'):
return False
if not isinstance(messageJson['object'], dict):
return False
if not messageJson['object'].get('type'):
return False
if messageJson['object']['type'] != 'Event':
return False
print('Event arriving')
if not messageJson['object'].get('startTime'):
print('No event start time')
return False
if not messageJson['object'].get('actor'):
print('No event actor')
return False
if not messageJson['object'].get('content'):
print('No event content')
return False
if not messageJson['object'].get('name'):
print('No event name')
return False
if not messageJson['object'].get('uuid'):
print('No event UUID')
return False
print('Event detected')
return True
def isBlogPost(postJsonObject: {}) -> bool: def isBlogPost(postJsonObject: {}) -> bool:
"""Is the given post a blog post? """Is the given post a blog post?
""" """

View File

@ -29,6 +29,7 @@ from utils import removeIdEnding
from utils import getProtocolPrefixes from utils import getProtocolPrefixes
from utils import getFileCaseInsensitive from utils import getFileCaseInsensitive
from utils import searchBoxPosts from utils import searchBoxPosts
from utils import isEventPost
from utils import isBlogPost from utils import isBlogPost
from utils import updateRecentPostsCache from utils import updateRecentPostsCache
from utils import getNicknameFromActor from utils import getNicknameFromActor
@ -4019,20 +4020,35 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int,
translate['Reply to this post'] + \ translate['Reply to this post'] + \
' |" src="/' + iconsDir + '/reply.png"/></a>\n' ' |" src="/' + iconsDir + '/reply.png"/></a>\n'
isEvent = isEventPost(postJsonObject)
editStr = '' editStr = ''
if fullDomain + '/users/' + nickname in postJsonObject['actor']: if fullDomain + '/users/' + nickname in postJsonObject['actor']:
if '/statuses/' in postJsonObject['object']['id']: if '/statuses/' in postJsonObject['object']['id']:
if isBlogPost(postJsonObject): if isBlogPost(postJsonObject):
blogPostId = postJsonObject['object']['id']
editStr += \ editStr += \
'<a class="imageAnchor" href="/users/' + nickname + \ '<a class="imageAnchor" href="/users/' + nickname + \
'/tlblogs?editblogpost=' + \ '/tlblogs?editblogpost=' + \
postJsonObject['object']['id'].split('/statuses/')[1] + \ blogPostId.split('/statuses/')[1] + \
'?actor=' + actorNickname + \ '?actor=' + actorNickname + \
'" title="' + translate['Edit blog post'] + '">' + \ '" title="' + translate['Edit blog post'] + '">' + \
'<img loading="lazy" title="' + \ '<img loading="lazy" title="' + \
translate['Edit blog post'] + '" alt="' + \ translate['Edit blog post'] + '" alt="' + \
translate['Edit blog post'] + \ translate['Edit blog post'] + \
' |" src="/' + iconsDir + '/edit.png"/></a>\n' ' |" src="/' + iconsDir + '/edit.png"/></a>\n'
elif isEvent:
eventPostId = postJsonObject['object']['id']
editStr += \
'<a class="imageAnchor" href="/users/' + nickname + \
'/tlblogs?editeventpost=' + \
eventPostId.split('/statuses/')[1] + \
'?actor=' + actorNickname + \
'" title="' + translate['Edit event'] + '">' + \
'<img loading="lazy" title="' + \
translate['Edit event'] + '" alt="' + \
translate['Edit event'] + \
' |" src="/' + iconsDir + '/edit.png"/></a>\n'
announceStr = '' announceStr = ''
if not isModerationPost and showRepeatIcon: if not isModerationPost and showRepeatIcon: