Admin can set instance metadata and logo from their profile screen

main
Bob Mottram 2019-11-13 20:50:23 +00:00
parent babeba65c1
commit dcefca19b0
17 changed files with 112 additions and 20 deletions

View File

@ -3221,7 +3221,7 @@ class PubServer(BaseHTTPRequestHandler):
# extract each image type
actorChanged=True
profileMediaTypes=['avatar','image','banner']
profileMediaTypes=['avatar','image','banner','instanceLogo']
for mType in profileMediaTypes:
if self.server.debug:
print('DEBUG: profile update extracting '+mType+' image from POST')
@ -3236,9 +3236,13 @@ class PubServer(BaseHTTPRequestHandler):
# Note: a .temp extension is used here so that at no time is
# an image with metadata publicly exposed, even for a few mS
filenameBase= \
self.server.baseDir+'/accounts/'+ \
nickname+'@'+self.server.domain+'/'+mType+'.temp'
if mType!='instanceLogo':
filenameBase= \
self.server.baseDir+'/accounts/'+ \
nickname+'@'+self.server.domain+'/'+mType+'.temp'
else:
filenameBase= \
self.server.baseDir+'/accounts/logo.temp'
filename,attachmentMediaType= \
saveMediaInFormPOST(mediaBytes,self.server.debug,filenameBase)
@ -3309,6 +3313,18 @@ class PubServer(BaseHTTPRequestHandler):
if fields['donateUrl']!=currentDonateUrl:
setDonationUrl(actorJson,fields['donateUrl'])
actorChanged=True
if fields.get('instanceTitle'):
currInstanceTitle=getConfigParam(self.server.baseDir,'instanceTitle')
if fields['instanceTitle']!=currInstanceTitle:
setConfigParam(self.server.baseDir,'instanceTitle',fields['instanceTitle'])
if fields.get('instanceDescriptionShort'):
currInstanceDescriptionShort=getConfigParam(self.server.baseDir,'instanceDescriptionShort')
if fields['instanceDescriptionShort']!=currInstanceDescriptionShort:
setConfigParam(self.server.baseDir,'instanceDescriptionShort',fields['instanceDescriptionShort'])
if fields.get('instanceDescription'):
currInstanceDescription=getConfigParam(self.server.baseDir,'instanceDescription')
if fields['instanceDescription']!=currInstanceDescription:
setConfigParam(self.server.baseDir,'instanceDescription',fields['instanceDescription'])
if fields.get('bio'):
if fields['bio']!=actorJson['summary']:
actorTags={}

View File

@ -173,5 +173,9 @@
"Donations link": "رابط التبرعات",
"Donate": "تبرع",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "Enllaç de donacions",
"Donate": "Donar",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "Dolen rhoddion",
"Donate": "Cyfrannu",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "Spenden Link",
"Donate": "Spenden",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "Donations link",
"Donate": "Donate",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "Enlace de donaciones",
"Donate": "Donar",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "Lien vers les dons",
"Donate": "Faire un don",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "Nasc síntiús",
"Donate": "Síntiús",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "दान लिंक",
"Donate": "दान करना",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "Link alle donazioni",
"Donate": "Donare",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "寄付リンク",
"Donate": "寄付する",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -169,5 +169,9 @@
"Show profile": "Veire lo perfil",
"SHOW MORE": "NE VEIRE MAI",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "Link de doações",
"Donate": "Doar",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "Ссылка на пожертвования",
"Donate": "жертвовать",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -173,5 +173,9 @@
"Donations link": "捐款连结",
"Donate": "捐",
"Change Password": "Change Password",
"Confirm Password": "Confirm Password"
"Confirm Password": "Confirm Password",
"Instance Title": "Instance Title",
"Instance Short Description": "Instance Short Description",
"Instance Description": "Instance Description",
"Instance Logo": "Instance Logo"
}

View File

@ -585,9 +585,25 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int)
with open(cssFilename, 'r') as cssFile:
editProfileCSS = cssFile.read()
instanceStr=''
moderatorsStr=''
adminNickname=getConfigParam(baseDir,'admin')
if path.startswith('/users/'+adminNickname+'/'):
instanceDescription=getConfigParam(baseDir,'instanceDescription')
instanceDescriptionShort=getConfigParam(baseDir,'instanceDescriptionShort')
instanceTitle=getConfigParam(baseDir,'instanceTitle')
instanceStr='<div class="container">'
instanceStr+=' '+translate['Instance Title']
instanceStr+=' <input type="text" name="instanceTitle" value="'+instanceTitle+'">'
instanceStr+=' '+translate['Instance Short Description']
instanceStr+=' <input type="text" name="instanceDescriptionShort" value="'+instanceDescriptionShort+'">'
instanceStr+=' '+translate['Instance Description']
instanceStr+=' <textarea id="message" name="instanceDescription" style="height:200px">'+instanceDescription+'</textarea>'
instanceStr+=' '+translate['Instance Logo']
instanceStr+=' <input type="file" id="instanceLogo" name="instanceLogo"'
instanceStr+=' accept=".png">'
instanceStr+='</div>'
moderators=''
moderatorsFile=baseDir+'/accounts/moderators.txt'
if os.path.isfile(moderatorsFile):
@ -650,7 +666,7 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int)
editProfileForm+=' <b>'+translate['Skills']+'</b><br>'
editProfileForm+=' '+translate['If you want to participate within organizations then you can indicate some skills that you have and approximate proficiency levels. This helps organizers to construct teams with an appropriate combination of skills.']
editProfileForm+=skillsStr+moderatorsStr
editProfileForm+=' </div>'
editProfileForm+=' </div>'+instanceStr
editProfileForm+=' <div class="container">'
editProfileForm+=' <b>'+translate['Danger Zone']+'</b><br>'
editProfileForm+=' <input type="checkbox" class=dangercheckbox" name="deactivateThisAccount">'+translate['Deactivate this account']+'<br>'