def get(self): if 'tabselect' in self.request.GET: tabselect = self.request.get('tabselect') else: tabselect='general' self.render_template('admin', {'news_list' : NewsArticleNew.all().order('-date'), 'talk_list' : TalkNew.all().order('-date'), 'hack_list' : Hack.all().order('-date'), 'image_list' : Image.all(), 'image_height' : self.image_height, 'image_width' : self.image_width, 'members': Member.all(), 'message' : self.admin_message, 'tabselect':tabselect})
def post(self): post = self.request.POST kind=post['kind'] if kind== 'taglineform': properties = GeneralSiteProperties.all().get() if properties == None: properties = GeneralSiteProperties(tag_line=post['tagline']) properties.put() else: properties.tag_line = post['tagline'] properties.put() elif kind=="image_upload": if(self.request.get("picture")): try: if('resize' in post): pictureImage = Image(picture=images.resize(self.request.get("picture"),int(post['height']), int(post['width'])), name="no-name",title=" ",alt=" ") else: pictureImage = Image(picture=self.request.get("picture"),name="no-name",title=" ",alt=" ") if(post['alias']!=""): replace=True name=post['alias'] for other_image in Image.all(): if other_image.name == name : replace=False self.admin_message="You cannot use %s as an alias as it is used for another image" % name if replace : pictureImage.name=name if(post['title']!=""): pictureImage.name=post['title'] if(post['alt']!=""): pictureImage.name=post['alt'] pictureImage.put() self.admin_message = 'Image uploaded' except RequestTooLargeError: self.admin_message = 'Image not uploaded - too large' except TypeError: self.admin_message = 'Width and Height have to be integers' else: self.admin_message = 'You need to actually select a picture!' kind='image' else : things_deleted = 0 for entry_key in self.request.POST.getall('delete_entry'): try: entry_key = Key(entry_key) except BadKeyError: # Wrong syntax for a key, move on to next key. continue if(kind=='news'): thing = NewsArticleNew.get(entry_key) elif(kind=='talk'): thing = TalkNew.get(entry_key) elif(kind=='hack'): thing = Hack.get(entry_key) if thing: thing.delete() things_deleted += 1 # Else, not article has this key. self.admin_message = '%d %s(s) deleted.' % (things_deleted,self.thing_descriptors.get(kind)) self.render_template('admin', {'news_list' : NewsArticleNew.all().order('-date'), 'talk_list' : TalkNew.all().order('-date'), 'hack_list' : Hack.all().order('-date'), 'image_list' : Image.all(), 'image_height' : self.image_height, 'image_width' : self.image_width, 'members': Member.all(), 'message' : self.admin_message, 'tabselect':kind})