def test_delete_alias(self): create_employee(username='******') alias = logic.alias.save_alias('jane', 'janed') self.assertEqual(Alias.query().count(), 1) logic.alias.delete_alias(alias.key.id()) self.assertEqual(Alias.query().count(), 0)
def test_save_alias(self): johnd = create_employee(username='******') self.assertEqual(Alias.query().count(), 0) alias = logic.alias.save_alias('johnny', 'johnd') self.assertEqual(Alias.query().count(), 1) self.assertEqual(alias.name, 'johnny') self.assertEqual(alias.owner_key, johnd.key)
def name_for_alias(alias_name): alias = Alias.query(Alias.name == alias_name).get() if alias: employee = alias.owner_key.get() if employee: return employee.username else: return alias_name
def get(self): upload_url = blobstore.create_upload_url('/upload') templates, aliases = Template.query().order(Template.key).fetch(), Alias.query().order(Template.key).fetch() #templates.extend(aliases) templates = [ t.key.string_id() for t in templates ] templates.sort() template = JINJA_ENVIRONMENT.get_template('form.html') self.response.write(template.render({'upload_url': upload_url, 'templates': templates}))
def aliases(): return render_template( 'aliases.html', aliases=Alias.query().fetch(), )
def get_alias(alias): return Alias.query(Alias.name == alias).get()