def initiate_password_reset(email): if valid_email(email) and user_by_email(email): token = uuid.uuid4().hex expiry = time.time() + 3600 ForgotToken(token=token, expiry=expiry, email=email).put() reset_link = redirect_to("/forgot/reset?token=%s" % token).headers["Location"] t1 = file("activate.txt", "r").read() t2 = fill("{{", "}}", t1, dict(reset_link=reset_link).get) t = fill("<dz:", ">", t2, dict(site_name=site_name()).get) send(email, "Password reset", markdown(t)) else: return "invalid email address"
def initiate_password_reset(email): if valid_email(email) and user_by_email(email): token = uuid.uuid4().hex expiry = time.time() + 3600 ForgotToken(token=token, expiry=expiry, email=email).put() reset_link = redirect_to('/forgot/reset?token=%s' % token).headers['Location'] t1 = file('activate.txt','r').read() t2 = fill('{{','}}',t1,dict(reset_link=reset_link).get) t = fill('<dz:','>',t2,dict(site_name=site_name()).get) send(email,'Password reset',markdown(t)) else: return 'invalid email address'
def initiate_password_reset(email): if valid_email(email) and user_by_email(email): token = uuid.uuid4().hex expiry = time.time() + 3600 ForgotToken(token=token, expiry=expiry, email=email).put() reset_link = redirect_to('/forgot/reset?token=%s' % token).headers['Location'] t1 = file('activate.txt', 'r').read() t2 = fill('{{', '}}', t1, dict(reset_link=reset_link).get) t = fill('<dz:', '>', t2, dict(site_name=site_name()).get) send(email, 'Password reset', markdown(t)) else: return 'invalid email address'
def __init__(self, id): def item_list(items, app, relation): count = 1 lines = [] items.sort(key=lambda a: a[1]) for item, label in items: link = link_to(label, '/' + app + '/' + str(item)) remove_url = url_for(str(id), relation, str(item), 'remove') trash = removal_icon(remove_url) lines.append('<tr><td>%s</td><td>%s</td></tr>' % (link, trash)) rows = ''.join(lines) button_name = 'ADD_' + relation.upper() + '_BUTTON' return form() + """ <input type=text class="text_field" id=%(relation)s name=%(relation)s size=20> <input type=submit class="field_button" value="Add" name="%(button_name)s"></form><br> <div class="group_relationships_list"> <table> %(rows)s </table> </div> """ % locals() group = Groups.get(id) self.id = id self.members = self.subgroups = self.authorizations = 'nada' self.fields = show_group_fields.show() self.name = 'name' self.members = item_list(group.members, 'users', 'member') self.subgroups = item_list(group.subgroups, 'groups', 'subgroup') items = [(r.user, r.activity, r.subject1, r.subject2, r.timestamp, how_long_ago(r.timestamp)) for r in audit_log(group.name)] self.audit_log = browse(items, labels=[ 'User', 'Activity', 'Subject1', 'Subject2', 'Timestamp', 'When' ]) self.relations = fill( '{{', '}}', """ <table class="transparent" width=100%><tr> <td width=33% valign=top> <H2>Users</H2> {{members}} </td><td width=33% valign=top> <H2>Includes</H2> {{subgroups}} </td><td width=33% valign=top> </td></tr></table> <br> <br> {{audit_log}} """, self)
def __init__(self, id): def item_list(items, app, relation): count = 1 lines = [] items.sort(key=lambda a: a[1]) for item, label in items: link = link_to(label,'/'+app+'/'+str(item)) remove_url = url_for(str(id), relation, str(item), 'remove') trash = removal_icon(remove_url) lines.append('<tr><td>%s</td><td>%s</td></tr>' % ( link, trash)) rows = ''.join(lines) button_name = 'ADD_' + relation.upper() + '_BUTTON' return form() + """ <input type=text class="text_field" id=%(relation)s name=%(relation)s size=20> <input type=submit class="field_button" value="Add" name="%(button_name)s"></form><br> <div class="group_relationships_list"> <table> %(rows)s </table> </div> """ % locals() group = Groups.get(id) self.id = id self.members = self.subgroups = self.authorizations = 'nada' self.fields = show_group_fields.show() self.name = 'name' self.members = item_list(group.members, 'users', 'member') self.subgroups = item_list(group.subgroups,'groups', 'subgroup') items = [(r.user,r.activity,r.subject1,r.subject2,r.timestamp,how_long_ago(r.timestamp)) for r in audit_log(group.name)] self.audit_log = browse(items,labels=['User','Activity','Subject1','Subject2','Timestamp','When']) self.relations = fill('{{','}}',""" <table class="transparent" width=100%><tr> <td width=33% valign=top> <H2>Users</H2> {{members}} </td><td width=33% valign=top> <H2>Includes</H2> {{subgroups}} </td><td width=33% valign=top> </td></tr></table> <br> <br> {{audit_log}} """,self)
def index(self): def get_categories(apps, selector): items = ['Miscellaneous'] for app in apps: if app.categories: for category in app.categories: items.append(category) items = sorted(set(items), key=lambda a: a.lower()) return '<ul>%s</ul>' % ''.join('<li id="%s">%s</li>' % \ (selector+'-'+id_for(i),i) for i in items) installed_categories_list = get_categories(installed_apps, 'installed') not_installed_categories_list = get_categories(uninstalled_apps, 'uninstalled') apps = installed_apps if user.is_administrator: apps += uninstalled_apps content = apps_list_tpl % ''.join(app_info_tpl % a for a in installed_apps) installed_app_count = len(installed_apps) app_count = len(installed_apps) + len(uninstalled_apps) user_app_count = len(user_apps) selected_apps = content if simple_format and True: content = [] content.append(html.tag('h2', 'Installed')) for app in sorted(installed_apps, key=lambda a: a.name.lower()): content.append('<a href="/apps/%(id)s">%(name)s</a> ' % dict(id=id_for(app.name), name=app.name)) content.append(html.tag('h2', 'Not Installed')) for app in sorted(uninstalled_apps, key=lambda a: a.name.lower()): content.append('<a href="/apps/%(id)s">%(name)s</a> ' % dict(id=id_for(app.name), name=app.name)) return page(''.join(content), title='Apps') tpl = load('main_panel.html') content = fill('{{', '}}', tpl, locals().get) p = page('<content>', title='Apps', css=css, js=js) p.content = p.content.replace('<content>', content) return p
def index(self): def get_categories(apps, selector): items = ['Miscellaneous'] for app in apps: if app.categories: for category in app.categories: items.append(category) items = sorted(set(items), key=lambda a:a.lower()) return '<ul>%s</ul>' % ''.join('<li id="%s">%s</li>' % \ (selector+'-'+id_for(i),i) for i in items) installed_categories_list = get_categories(installed_apps,'installed') not_installed_categories_list = get_categories(uninstalled_apps,'uninstalled') apps = installed_apps if user.is_administrator: apps += uninstalled_apps content = apps_list_tpl % ''.join(app_info_tpl % a for a in installed_apps) installed_app_count = len(installed_apps) app_count = len(installed_apps) + len(uninstalled_apps) user_app_count = len(user_apps) selected_apps = content if simple_format and True: content = [] content.append(html.tag('h2','Installed')) for app in sorted(installed_apps, key=lambda a:a.name.lower()): content.append('<a href="/apps/%(id)s">%(name)s</a> ' % dict(id=id_for(app.name), name=app.name)) content.append(html.tag('h2','Not Installed')) for app in sorted(uninstalled_apps, key=lambda a:a.name.lower()): content.append('<a href="/apps/%(id)s">%(name)s</a> ' % dict(id=id_for(app.name), name=app.name)) return page(''.join(content), title='Apps') tpl = load('main_panel.html') content = fill('{{', '}}', tpl, locals().get) p = page('<content>', title='Apps', css=css, js=js) p.content = p.content.replace('<content>',content) return p
def __init__(self, id): def item_list(items, app, relation): count = 1 lines = [] items.sort(key=lambda a: a[1]) for item, label in items: link = link_to(label, "/" + app + "/" + str(item)) remove_url = url_for(str(id), relation, str(item), "remove") trash = removal_icon(remove_url) lines.append("<tr><td>%s</td><td>%s</td></tr>" % (link, trash)) rows = "".join(lines) button_name = "ADD_" + relation.upper() + "_BUTTON" return ( form() + """ <input type=text class="text_field" id=%(relation)s name=%(relation)s size=20> <input type=submit class="field_button" value="Add" name="%(button_name)s"></form><br> <div class="group_relationships_list"> <table> %(rows)s </table> </div> """ % locals() ) group = Groups.get(id) self.id = id self.members = self.subgroups = self.authorizations = "nada" self.fields = show_group_fields.show() self.name = "name" self.members = item_list(group.members, "users", "member") self.subgroups = item_list(group.subgroups, "groups", "subgroup") items = [ (r.user, r.activity, r.subject1, r.subject2, r.timestamp, how_long_ago(r.timestamp)) for r in audit_log(group.name) ] self.audit_log = browse(items, labels=["User", "Activity", "Subject1", "Subject2", "Timestamp", "When"]) self.relations = fill( "{{", "}}", """ <table class="transparent" width=100%><tr> <td width=33% valign=top> <H2>Users</H2> {{members}} </td><td width=33% valign=top> <H2>Includes</H2> {{subgroups}} </td><td width=33% valign=top> </td></tr></table> <br> <br> {{audit_log}} """, self, )