diff --git a/daemon.py b/daemon.py index 249b2d56..b83a335d 100644 --- a/daemon.py +++ b/daemon.py @@ -107,6 +107,7 @@ from roles import setRole from roles import clearModeratorStatus from skills import outboxSkills from availability import outboxAvailability +from webinterface import htmlCalendarDeleteConfirm from webinterface import htmlDeletePost from webinterface import htmlAbout from webinterface import htmlRemoveSharedItem @@ -1519,6 +1520,28 @@ class PubServer(BaseHTTPRequestHandler): self.server.GETbusy=False return + # Show confirmation for deleting a calendar event + if htmlGET and '/users/' in self.path: + if '/eventdelete' in self.path and \ + '?time=' in self.path and \ + '?id=' in self.path: + postId=self.path.split('?id=')[1] + if '?' in postId: + postId=postId.split('?')[0] + postTime=self.path.split('?time=')[1] + if '?' in postTime: + postTime=postTime.split('?')[0] + # show the confirmation screen screen + msg=htmlCalendarDeleteConfirm(self.server.translate, \ + self.server.baseDir,self.path, \ + self.server.httpPrefix, \ + self.server.domainFull, + postId,postTime).encode() + self._set_headers('text/html',len(msg),cookie) + self._write(msg) + self.server.GETbusy=False + return + self._benchmarkGETtimings(GETstartTime,GETtimings,30) # search for emoji by name diff --git a/translations/oc.json b/translations/oc.json index 51b1da79..d0435fe0 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -104,8 +104,7 @@ "Options for": "Opcions per", "Stop following": "Quitar de seguir", "Follow": "Seguir", - "Delete this post": "Suprimir aquesta publicacion ?", - "Delete this event": "Suprimir aquesta publicacion ?", + "Delete this post?": "Suprimir aquesta publicacion ?", "No": "Non", "Yes": "Òc", "Info": "Info", @@ -163,6 +162,7 @@ "Write your post text below.": "Escrivètz lo tèxte de la publicacion çai-jos.", "Reply to this post": "Respondre a aquesta publicacion", "Delete this post": "Suprimir aquesta publicacion", + "Delete this event": "Suprimir aquesta publicacion", "Undo the like": "Quitar d’aimar la publicacion", "Like this post": "Aimar la publicacion", "Undo the repeat": "Anullar lo partatge", diff --git a/webinterface.py b/webinterface.py index fe77f968..69bac092 100644 --- a/webinterface.py +++ b/webinterface.py @@ -3362,6 +3362,52 @@ def htmlDeletePost(recentPostsCache: {},maxRecentPosts: int, \ deletePostStr+=htmlFooter() return deletePostStr +def htmlCalendarDeleteConfirm(translate: {},baseDir: str, \ + path: str,httpPrefix: str, \ + domainFull: str,postId: str,postTime: str) -> str: + """Shows a screen asking to confirm the deletion of a calendar event + """ + iconsDir=getIconsDir(baseDir) + nickname=getNicknameFromActor(path) + actor=httpPrefix+'://'+domainFull+'/users/'+nickname + domain,port=getDomainFromActor(actor) + messageId=actor+'/'+postId + + postFilename=locatePost(baseDir,nickname,domain,messageId) + if not postFilename: + return None + + postJsonObject=loadJson(postFilename) + if not postJsonObject: + return None + + if os.path.isfile(baseDir+'/img/delete-background.png'): + if not os.path.isfile(baseDir+'/accounts/delete-background.png'): + copyfile(baseDir+'/img/delete-background.png', \ + baseDir+'/accounts/delete-background.png') + + deletePostStr=None + cssFilename=baseDir+'/epicyon-profile.css' + if os.path.isfile(baseDir+'/epicyon.css'): + cssFilename=baseDir+'/epicyon.css' + with open(cssFilename, 'r') as cssFile: + profileStyle = cssFile.read() + if httpPrefix!='https': + profileStyle=profileStyle.replace('https://',httpPrefix+'://') + deletePostStr=htmlHeader(cssFilename,profileStyle) + deletePostStr+='

'+postTime+'

' + deletePostStr+='
' + deletePostStr+='

'+translate['Delete this event']+'

' + deletePostStr+='
' + deletePostStr+=' ' + deletePostStr+=' ' + deletePostStr+=' ' + deletePostStr+=' ' + deletePostStr+='
' + deletePostStr+='
' + deletePostStr+=htmlFooter() + return deletePostStr + def htmlFollowConfirm(translate: {},baseDir: str, \ originPathStr: str, \ followActor: str, \ @@ -3689,7 +3735,7 @@ def htmlCalendarDay(translate: {}, \ deleteButtonStr='' if postId: - deleteButtonStr=''+translate['Delete this event']+' |' + deleteButtonStr=''+translate['Delete this event']+' |' if eventTime and eventDescription and eventPlace: calendarStr+=''+eventTime+''+eventPlace+'
'+eventDescription+''+deleteButtonStr+'\n'