def post(self): user = users.get_current_user() tab_id = cgi.escape(self.request.get('tab_id')) tab_content = cgi.escape(self.request.get('tab_content')).strip() name = cgi.escape(self.request.get('name')) description = cgi.escape(self.request.get('description')).strip() instrument = cgi.escape(self.request.get('instrument')).lower() tuning = cgi.escape(self.request.get('tuning')).lower() if not tab_id: tab = Tab( author = user, tab_content = tab_content, name = name, description = description, instrument = instrument, tuning = helper.format_tuning(tuning) ) tab.put() tab_id = tab.key().id() else: tab = Tab.get_by_id(long(tab_id)) tab.tab_content = tab_content tab.name = name tab.description = description tab.instrument = instrument tab.tuning = helper.format_tuning(tuning) tab.put() self.redirect("/edit?tab_id=%d" % long(tab_id))
def get(self): user = users.get_current_user() tab_id = long(cgi.escape(self.request.get('tab_id'))) toCopy = Tab.get_by_id(tab_id) tab = { 'author': user, 'tab_content': toCopy.tab_content, 'name': toCopy.name + " Copy", 'description': toCopy.description, 'instrument': toCopy.instrument, 'tuning': helper.format_tuning(toCopy.tuning) } template_values = { 'user': user, 'tab': tab, 'logout_url': users.create_logout_url("/"), 'login_url': users.create_login_url("/") } self.response.out.write(template.render(template_dir+"create.html", template_values))