Event edit button

main
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 datetime
import time
from utils import isEventPost
from utils import removeIdEnding
from utils import getProtocolPrefixes
from utils import isBlogPost
@ -774,43 +775,6 @@ def receiveUndo(session, baseDir: str, httpPrefix: str,
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,
httpPrefix: str, domain: str, port: int,
sendThreads: [], postLog: [], cachedWebfingers: {},

View File

@ -280,5 +280,6 @@
"Maximum attendees": "الحد الأقصى للحضور",
"Ticket URL": "عنوان URL للتذكرة",
"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",
"Ticket URL": "URL de l'entrada",
"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",
"Ticket URL": "URL y tocyn",
"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",
"Ticket URL": "Ticket URL",
"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",
"Ticket URL": "Ticket URL",
"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",
"Ticket URL": "URL del ticket",
"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",
"Ticket URL": "URL du ticket",
"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",
"Ticket URL": "URL na dticéad",
"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": "अधिकतम उपस्थित",
"Ticket URL": "टिकट URL",
"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",
"Ticket URL": "URL del biglietto",
"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": "最大参加者",
"Ticket URL": "チケットURL",
"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",
"Ticket URL": "Ticket URL",
"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",
"Ticket URL": "URL do bilhete",
"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": "Максимальное количество участников",
"Ticket URL": "URL билета",
"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": "参加人数上限",
"Ticket URL": "工单URL",
"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
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:
"""Is the given post a blog post?
"""

View File

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