forked from indymedia/epicyon
Function to remove calendar event
parent
13afcca48f
commit
56b101a6fc
18
daemon.py
18
daemon.py
|
@ -175,6 +175,7 @@ from schedule import runPostSchedule
|
|||
from schedule import runPostScheduleWatchdog
|
||||
from schedule import removeScheduledPosts
|
||||
from outbox import postMessageToOutbox
|
||||
from happening import removeCalendarEvent
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -4792,6 +4793,16 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
pageNumberStr=pageNumberStr.split('&')[0]
|
||||
if pageNumberStr.isdigit():
|
||||
pageNumber=int(pageNumberStr)
|
||||
yearStr=None
|
||||
if 'year=' in removePostConfirmParams:
|
||||
yearStr=removePostConfirmParams.split('year=')[1]
|
||||
if '&' in yearStr:
|
||||
yearStr=yearStr.split('&')[0]
|
||||
monthStr=None
|
||||
if 'month=' in removePostConfirmParams:
|
||||
monthStr=removePostConfirmParams.split('month=')[1]
|
||||
if '&' in monthStr:
|
||||
monthStr=monthStr.split('&')[0]
|
||||
if '/statuses/' in removeMessageId:
|
||||
removePostActor=removeMessageId.split('/statuses/')[0]
|
||||
if originPathStr in removePostActor:
|
||||
|
@ -4805,6 +4816,13 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
}
|
||||
self.postToNickname=getNicknameFromActor(removePostActor)
|
||||
if self.postToNickname:
|
||||
if monthStr and yearStr:
|
||||
if monthStr.isdigit() and yearStr.isdigit():
|
||||
removeCalendarEvent(self.server.baseDir, \
|
||||
self.postToNickname, \
|
||||
self.server.domain, \
|
||||
int(yearStr),int(monthStr), \
|
||||
removeMessageId)
|
||||
self._postToOutboxThread(deleteJson)
|
||||
if pageNumber==1:
|
||||
self._redirect_headers(originPathStr+'/outbox',cookie)
|
||||
|
|
23
happening.py
23
happening.py
|
@ -369,3 +369,26 @@ def getCalendarEvents(baseDir: str,nickname: str,domain: str, \
|
|||
calendarFile.close()
|
||||
|
||||
return events
|
||||
|
||||
def removeCalendarEvent(baseDir: str,nickname: str,domain: str, \
|
||||
year: int,monthNumber: int,messageId: str) -> None:
|
||||
"""Removes a calendar event
|
||||
"""
|
||||
calendarFilename= \
|
||||
baseDir+'/accounts/'+nickname+'@'+domain+ \
|
||||
'/calendar/'+str(year)+'/'+str(monthNumber)+'.txt'
|
||||
if not os.path.isfile(calendarFilename):
|
||||
return
|
||||
if '/' in messageId:
|
||||
messageId=messageId.replace('/','#')
|
||||
if messageId not in open(calendarFilename).read():
|
||||
return
|
||||
lines=None
|
||||
with open(calendarFilename, "r") as f:
|
||||
lines = f.readlines()
|
||||
if not lines:
|
||||
return
|
||||
with open(calendarFilename, "w+") as f:
|
||||
for line in lines:
|
||||
if messageId not in line:
|
||||
f.write(line)
|
||||
|
|
|
@ -3400,6 +3400,9 @@ def htmlCalendarDeleteConfirm(translate: {},baseDir: str, \
|
|||
deletePostStr+='<center>'
|
||||
deletePostStr+=' <p class="followText">'+translate['Delete this event']+'</p>'
|
||||
deletePostStr+=' <form method="POST" action="'+actor+'/rmpost">'
|
||||
deletePostStr+=' <input type="hidden" name="year" value="'+str(year)+'">'
|
||||
deletePostStr+=' <input type="hidden" name="month" value="'+str(monthNumber)+'">'
|
||||
deletePostStr+=' <input type="hidden" name="day" value="'+str(dayNumber)+'">'
|
||||
deletePostStr+=' <input type="hidden" name="pageNumber" value="1">'
|
||||
deletePostStr+=' <input type="hidden" name="messageId" value="'+messageId+'">'
|
||||
deletePostStr+=' <button type="submit" class="button" name="submitYes">'+translate['Yes']+'</button>'
|
||||
|
|
Loading…
Reference in New Issue