def putDj(email=None, fullname=None, username=None, password=None, edit_dj=None): if edit_dj is None: if None in (email, fullname, username, password): raise Exception("Insufficient fields for new Dj") dj = models.Dj(fullname=fullname, lowername=fullname.lower(), email=email, username=username, password_hash=hash_password(password)) else: dj = getDj(edit_dj) # In case they passed a key if dj is None: raise Exception("Quantum Dj nonexistance error") if fullname is not None: dj.fullname = fullname dj.lowername = fullname.lower() if email is not None: dj.email = email if username is not None: # Although this should be an immutable property dj.username = username if password is not None: dj.password_hash = hash_password(password) if dj is not None: dj.put() return mcset(dj, DJ_ENTRY %dj.key()) return None
def reset_password(self, put=True): reset_key = ''.join(random.choice(string.ascii_letters + string.digits) for x in range(20)) self.pw_reset_expire=datetime.datetime.now() + datetime.timedelta(2) self.pw_reset_hash=hash_password(reset_key) if put: self.put() return reset_key
def __init__(self, email=None, fullname=None, username=None, password=None, fix_email=True, **kwargs): if None in (email, fullname, username, password): raise ModelError("Insufficient fields for new Dj") super(Dj, self).__init__(fullname=fullname, email=(fix_bare_email(email) if fix_email else email), username=username, password_hash=hash_password(password), **kwargs)
def __init__(self, raw=None, raw_key=None, email=None, fullname=None, username=None, password=None, fix_email=True): if raw is not None: super(Dj, self).__init__(raw=raw) return elif raw_key is not None: super(Dj, self).__init__(raw_key=raw_key) return if None in (email, fullname, username, password): raise Exception("Insufficient fields for new Dj") super(Dj, self).__init__(fullname=fullname, email=(fix_bare_email(email) if fix_email else email), username=username, password_hash=hash_password(password))
def password(self, password): self.raw.password_hash = hash_password(password)
def get(self): labels = [ "Manage DJs", "Manage Programs", "Manage Permissions", "Manage Albums", "Manage Genres", "Manage Blog", "Manage Events" ] for l in labels: if not models.getPermission(l): permission = models.Permission(title=l, dj_list=[]) permission.put() seth = models.getDjByEmail("*****@*****.**") if not seth: seth = models.Dj(fullname='Seth Glickman', lowername='seth glickman', email='*****@*****.**', username='******', password_hash=hash_password('testme')) seth.put() program = models.Program( title='Seth\'s Show', slug='seth', desc='This is the show where Seth plays his favorite music.', dj_list=[seth.key()], page_html='a <b>BOLD</b> show!') program.put() for l in labels: permission = models.getPermission(l) if seth.key() not in permission.dj_list: permission.dj_list.append(seth.key()) permission.put() if not models.getLastPosts(3): post1 = models.BlogPost( title="Blog's first post!", text="This is really just filler text on the first post.", slug="first-post", post_date=datetime.datetime.now()) post1.put() time.sleep(2) post2 = models.BlogPost(title="Blog's second post!", text="More filler text, alas.", slug="second-post", post_date=datetime.datetime.now()) post2.put() artists = [ "Bear In Heaven", "Beck", "Arcade Fire", "Andrew Bird", "The Antlers", "Arcade Fire", "The Beach Boys", "Brian Wilson", "The Beatles", "Beethoven", "Beirut", "Belle & Sebastian", "Benji Hughes", "Club 8", "Crayon Fields", ] for a in artists: if not models.ArtistName.all().filter("artist_name =", a).fetch(1): ar = models.ArtistName( artist_name=a, lowercase_name=a.lower(), search_names=models.artistSearchName(a).split()) ar.put() self.session.add_flash( "Permissions set up, ArtistNames set up, Blog posts set up, DJ Seth entered." ) self.redirect('/')
def get(self): labels = [ "Manage DJs", "Manage Programs", "Manage Permissions", "Manage Albums", "Manage Genres", "Manage Blog", "Manage Events", ] for l in labels: if not models.getPermission(l): permission = models.Permission(title=l, dj_list=[]) permission.put() seth = models.getDjByEmail("*****@*****.**") if not seth: seth = models.Dj( fullname="Seth Glickman", lowername="seth glickman", email="*****@*****.**", username="******", password_hash=hash_password("testme"), ) seth.put() program = models.Program( title="Seth's Show", slug="seth", desc="This is the show where Seth plays his favorite music.", dj_list=[seth.key()], page_html="a <b>BOLD</b> show!", ) program.put() for l in labels: permission = models.getPermission(l) if seth.key() not in permission.dj_list: permission.dj_list.append(seth.key()) permission.put() if not models.getLastPosts(3): post1 = models.BlogPost( title="Blog's first post!", text="This is really just filler text on the first post.", slug="first-post", post_date=datetime.datetime.now(), ) post1.put() time.sleep(2) post2 = models.BlogPost( title="Blog's second post!", text="More filler text, alas.", slug="second-post", post_date=datetime.datetime.now(), ) post2.put() artists = [ "Bear In Heaven", "Beck", "Arcade Fire", "Andrew Bird", "The Antlers", "Arcade Fire", "The Beach Boys", "Brian Wilson", "The Beatles", "Beethoven", "Beirut", "Belle & Sebastian", "Benji Hughes", "Club 8", "Crayon Fields", ] for a in artists: if not models.ArtistName.all().filter("artist_name =", a).fetch(1): ar = models.ArtistName( artist_name=a, lowercase_name=a.lower(), search_names=models.artistSearchName(a).split() ) ar.put() self.session.add_flash("Permissions set up, ArtistNames set up, Blog posts set up, DJ Seth entered.") self.redirect("/")