def get(self): the_user = self.user the_band_key_str = self.request.get('bk', '0') if the_band_key_str == '0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_key_str) if not is_authorized_to_edit_band(the_band_key, the_user): return the_band = band.get_band(the_band_key) the_sections = band.get_sections_from_keys(the_band.sections) the_info = [] for s in the_sections: the_name = string.replace(string.replace(s.name, "'", ""), '"', '') # ugly: disallow quotes the_info.append([the_name, s.key.urlsafe(), the_name]) template_args = { 'the_band': the_band, 'the_info': json.dumps(the_info) } self.render_template('band_setup_sections.html', template_args)
def get(self): """ handles the 'confirm member' button in the band info page """ the_user = self.user the_member_keyurl=self.request.get('mk','0') the_band_keyurl=self.request.get('bk','0') if the_member_keyurl == '0' or the_band_keyurl == '0': return # todo what to do? the_member_key = member.member_key_from_urlsafe(the_member_keyurl) the_band_key = band.band_key_from_urlsafe(the_band_keyurl) if not is_authorized_to_edit_band(the_band_key,the_user): return the_member = member.get_member(the_member_key) assoc.confirm_member_for_band_key(the_member, the_band_key) # if the user happens to be logged in, invalidate his cached list of bands and # bands for which he can edit gigs the_member.invalidate_member_bandlists(self, the_member_key) the_band = band.get_band(the_band_key) goemail.send_band_accepted_email(the_member.email_address, the_band) return self.redirect('/band_info.html?bk={0}'.format(the_band_keyurl))
def get(self): the_user = self.user the_band_key_str=self.request.get('bk','0') if the_band_key_str=='0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_key_str) if not is_authorized_to_edit_band(the_band_key,the_user): return the_band = band.get_band(the_band_key) the_sections = band.get_sections_from_keys(the_band.sections) the_info = [] for s in the_sections: the_name = string.replace(string.replace(s.name,"'",""),'"','') # ugly: disallow quotes the_info.append([the_name, s.key.urlsafe(), the_name]) template_args = { 'the_band' : the_band, 'the_info' : json.dumps(the_info) } self.render_template('band_setup_sections.html', template_args)
def get(self): """ handles the 'confirm member' button in the band info page """ the_user = self.user the_member_keyurl = self.request.get('mk', '0') the_band_keyurl = self.request.get('bk', '0') if the_member_keyurl == '0' or the_band_keyurl == '0': return # todo what to do? the_member_key = member.member_key_from_urlsafe(the_member_keyurl) the_band_key = band.band_key_from_urlsafe(the_band_keyurl) if not is_authorized_to_edit_band(the_band_key, the_user): return the_member = member.get_member(the_member_key) assoc.confirm_member_for_band_key(the_member, the_band_key) # if the user happens to be logged in, invalidate his cached list of bands and # bands for which he can edit gigs the_member.invalidate_member_bandlists(self, the_member_key) the_band = band.get_band(the_band_key) goemail.send_band_accepted_email(the_member.email_address, the_band) return self.redirect('/band_info.html?bk={0}'.format(the_band_keyurl))
def post(self): """ post handler - wants an ak and sk """ the_user = self.user the_section_keyurl = self.request.get('sk', '0') the_member_keyurl = self.request.get('mk', '0') the_band_keyurl = self.request.get('bk', '0') if the_section_keyurl == '0' or the_member_keyurl == '0' or the_band_keyurl == '0': raise Exception("Section, member and band must all be specified.") the_section_key = band.section_key_from_urlsafe(the_section_keyurl) the_member_key = member.member_key_from_urlsafe(the_member_keyurl) the_band_key = band.band_key_from_urlsafe(the_band_keyurl) oktochange = False if (the_user.key == the_member_key or the_user.is_superuser): oktochange = True else: the_assoc = assoc.get_assoc_for_band_key_and_member_key( the_user.key, the_band_key) if the_assoc is not None and the_assoc.is_band_admin: oktochange = True if (oktochange): assoc.set_default_section(the_member_key, the_band_key, the_section_key)
def post(self): """ post handler - wants an ak and sk """ the_user = self.user the_section_keyurl=self.request.get('sk','0') the_member_keyurl=self.request.get('mk','0') the_band_keyurl=self.request.get('bk','0') if the_section_keyurl=='0' or the_member_keyurl=='0' or the_band_keyurl=='0': raise Exception("Section, member and band must all be specified.") the_section_key = band.section_key_from_urlsafe(the_section_keyurl) the_member_key = member.member_key_from_urlsafe(the_member_keyurl) the_band_key = band.band_key_from_urlsafe(the_band_keyurl) oktochange=False if (the_user.key == the_member_key or the_user.is_superuser): oktochange=True else: the_assoc = assoc.get_assoc_for_band_key_and_member_key(the_user.key, the_band_key) if the_assoc is not None and the_assoc.is_band_admin: oktochange=True if (oktochange): assoc.set_default_section(the_member_key, the_band_key, the_section_key)
def make_page(self, the_user): the_band_key_url = self.request.get("bk", None) if the_band_key_url is None: raise gigoexceptions.GigoException( 'no band key passed to GigArchivePage handler') else: the_band_key = band.band_key_from_urlsafe(the_band_key_url) # make sure this member is actually in the band if assoc.confirm_user_is_member( the_user.key, the_band_key) is None and the_user.is_superuser is not True: raise gigoexceptions.GigoException( 'user called GigArchivePage handler but is not member') the_band = the_band_key.get() if the_band is None: raise gigoexceptions.GigoException( 'GigArchivePage handler called without a band') the_gigs = gig.get_gigs_for_band_keys(the_band_key, show_past=True) template_args = { 'the_user': the_user, 'the_band': the_band, 'the_gigs': the_gigs, 'the_date_formatter': member.format_date_for_member } self.render_template('band_gig_archive.html', template_args)
def make_page(self, the_user): the_band_key_url = self.request.get("bk", None) if the_band_key_url is None: raise gigoexceptions.GigoException( 'no band key passed to GigTrashcanPage handler') else: the_band_key = band.band_key_from_urlsafe(the_band_key_url) # make sure this member is actually a band admin if not assoc.get_admin_status_for_member_for_band_key( the_user, the_band_key) and not the_user.is_superuser: raise gigoexceptions.GigoException( 'user called GigTrashcanPage handler but is not admin') the_band = the_band_key.get() if the_band is None: raise gigoexceptions.GigoException( 'GigTrashcanPage handler calledd without a band') the_gigs = gig.get_trashed_gigs_for_band_key(the_band_key) template_args = { 'the_user': the_user, 'the_band': the_band, 'the_gigs': the_gigs, 'the_date_formatter': member.format_date_for_member } self.render_template('band_gig_trashcan.html', template_args)
def make_page(self, the_user): the_band_key_url=self.request.get("bk",None) if the_band_key_url is None: raise gigoexceptions.GigoException('no band key passed to GigArchivePage handler') else: the_band_key = band.band_key_from_urlsafe(the_band_key_url) # make sure this member is actually in the band if assoc.confirm_user_is_member(the_user.key, the_band_key) is None and the_user.is_superuser is not True: raise gigoexceptions.GigoException('user called GigArchivePage handler but is not member') the_band = the_band_key.get() if the_band is None: raise gigoexceptions.GigoException('GigArchivePage handler called without a band') the_gigs = gig.get_gigs_for_band_keys(the_band_key, show_past=True) template_args = { 'the_user' : the_user, 'the_band' : the_band, 'the_gigs' : the_gigs, 'the_date_formatter' : member.format_date_for_member } self.render_template('band_gig_archive.html', template_args)
def post(self): the_user = self.user the_band_key_str = self.request.get('bk', '0') if the_band_key_str == '0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_key_str) if not is_authorized_to_edit_band(the_band_key, the_user): return the_band = the_band_key.get() the_section_info = self.request.get('sectionInfo', None) if the_section_info is None: return new_sections = json.loads(the_section_info) # build a new list of sections. Make sure the sections are actually in the band. new_section_list = [] for n in new_sections: if n[1] == "": # this is a new section ns = band.new_section( the_band.key, string.replace(string.replace(n[0], "'", ""), '"', '')) ns.put() s = ns.key else: s = band.section_key_from_urlsafe(n[1]) old_section = s.get() if old_section.name != n[0]: old_section.name = string.replace( string.replace(n[0], "'", ""), '"', '') old_section.put() new_section_list.append(s) the_band.sections = new_section_list the_band.put() deleted_section_info = self.request.get('deletedSections', None) if deleted_section_info: the_deleted_sections = json.loads(deleted_section_info) if the_deleted_sections: section_keys_to_delete = [ band.section_key_from_urlsafe(x) for x in the_deleted_sections ] for d in section_keys_to_delete: band.delete_section_key(d) band.set_section_indices(the_band) return
def get(self): the_user = self.user the_band_keyurl = self.request.get('bk', '0') the_band_key = band.band_key_from_urlsafe(the_band_keyurl) self.response.headers['Content-Type'] = 'application/x-gzip' self.response.headers[ 'Content-Disposition'] = 'attachment; filename=archive.csv' the_band_key_url = self.request.get("bk", None) if the_band_key_url is None: raise gigoexceptions.GigoException( 'no band key passed to GigArchivePage handler') else: the_band_key = band.band_key_from_urlsafe(the_band_key_url) # make sure this member is actually in the band if assoc.confirm_user_is_member( the_user.key, the_band_key) is None and the_user.is_superuser is not True: raise gigoexceptions.GigoException( 'user called GigArchivePage handler but is not member') the_band = band.get_band(the_band_key) if the_band is None: raise gigoexceptions.GigoException( 'GigArchivePage handler called without a band') the_gigs = gig.get_gigs_for_band_keys(the_band_key, show_past=True) data = "date,name,status,committed,pay" for g in the_gigs: plans = plan.get_plans_for_gig_key(g.key, keys_only=True, plan_values=[1, 2]) # num=len([p for p in plans if p.value in [1,2]]) num = len(plans) stat = 0 if (g.status and g.status in [0, 1, 2]): stat = g.status data = u"{0}\n{1},\"{2}\",{3},{4},\"{5}\"".format( data, member.format_date_for_member(the_user, g.date, 'short'), g.title, gig.Gig.status_names[stat], num, g.paid) self.response.write(data)
def _make_page(self,the_user,the_band=None): """ produce the info page """ # find the band we're interested in if the_band is None: band_key_str = self.request.get("bk", None) if band_key_str is None: self.response.write('no band key passed in!') return # todo figure out what to do if there's no ID passed in the_band_key = band.band_key_from_urlsafe(band_key_str) the_band = band.get_band(the_band_key) if the_band is None: self.response.write('did not find a band!') return # todo figure out what to do if we didn't find it if the_user is None: the_user_is_associated = False the_user_is_confirmed = False the_user_admin_status = False the_user_is_superuser = False else: the_user_is_associated = assoc.get_associated_status_for_member_for_band_key(the_user, the_band_key) the_user_is_confirmed = assoc.get_confirmed_status_for_member_for_band_key(the_user, the_band_key) the_user_admin_status = assoc.get_admin_status_for_member_for_band_key(the_user, the_band_key) the_user_is_superuser = member.member_is_superuser(the_user) if the_user_admin_status or the_user_is_superuser: the_pending = assoc.get_pending_members_from_band_key(the_band_key) the_invited_assocs = assoc.get_invited_member_assocs_from_band_key(the_band_key) the_invited = [(x.key, member.get_member(x.member).name) for x in the_invited_assocs] else: the_pending = [] the_invited = [] member_links=None if the_band.member_links: member_links=[] link_list = the_band.member_links.split('\n') for l in link_list: link_info = l.split(':',1) if len(link_info) == 2: member_links.append([link_info[0].strip(), link_info[1].strip()]) template_args = { 'the_band' : the_band, 'the_user_is_associated': the_user_is_associated, 'the_user_is_confirmed': the_user_is_confirmed, 'the_user_is_band_admin': the_user_admin_status, 'the_pending_members': the_pending, 'the_invited_members': the_invited, 'the_member_links': member_links, 'num_sections': len(the_band.sections) } self.render_template('band_info.html', template_args)
def post(self): """ return the members for a band """ the_user = self.user the_band_key_str = self.request.get('bk', '0') if the_band_key_str == '0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_key_str) assocs = assoc.get_assocs_of_band_key(the_band_key=the_band_key, confirmed_only=True) the_members = member.get_member([a.member for a in assocs]) the_members = sorted(the_members, key=lambda member: member.lower_name) # now sort the assocs to be in the same order as the member list assocs = sorted(assocs, key=lambda a: [m.key for m in the_members].index(a.member)) assoc_info = [] the_user_is_band_admin = False for i in range(0, len(assocs)): a = assocs[i] m = the_members[i] if a.default_section: s = a.default_section.get().name else: s = None assoc_info.append({ 'name': (m.nickname if m.nickname else m.name), 'is_confirmed': a.is_confirmed, 'is_band_admin': a.is_band_admin, 'is_occasional': a.is_occasional, 'member_key': a.member, 'section': s, 'is_multisectional': a.is_multisectional, 'assoc': a }) if a.member == the_user.key: the_user_is_band_admin = a.is_band_admin the_section_keys = band.get_band(the_band_key).sections the_sections = band.get_sections_from_keys(the_section_keys) template_args = { 'the_band_key': the_band_key, 'the_assocs': assoc_info, 'the_sections': the_sections, 'the_user_is_band_admin': the_user_is_band_admin, 'the_date_formatter': member.format_date_for_member, } self.render_template('band_members.html', template_args)
def post(self): """ return the sections for a band """ the_user = self.user the_band_key_str = self.request.get('bk', '0') if the_band_key_str == '0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_key_str) the_band = band.get_band(the_band_key) the_section_index_str = self.request.get('ski', None) if the_section_index_str is None: the_section is None else: if the_section_index_str == 'None': the_section = None the_section_key = None else: the_section_key = the_band.sections[int(the_section_index_str)] the_section = the_section_key.get() the_assocs = assoc.get_assocs_of_band_key_for_section_key( the_band_key, the_section_key) if the_section is None and len(the_assocs) == 0: self.response.write("None") return member_keys = [a.member for a in the_assocs] the_members = member.get_member(member_keys) # make sure members and assocs are in the right order the_members = sorted(the_members, key=lambda m: member_keys.index(m.key)) someone_is_new = False the_user_is_band_admin = assoc.get_admin_status_for_member_for_band_key( the_user, the_band_key) template_args = { 'the_band': the_band, 'the_section': the_section, 'the_assocs': the_assocs, 'the_members': the_members, 'has_sections': the_band.sections and len(the_band.sections) > 0, 'the_user_is_band_admin': the_user_is_band_admin, 'someone_is_new': someone_is_new } self.render_template('band_sections.html', template_args)
def post(self): the_user = self.user the_band_key_str=self.request.get('bk','0') if the_band_key_str=='0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_key_str) if not is_authorized_to_edit_band(the_band_key,the_user): return the_band = the_band_key.get() the_section_info = self.request.get('sectionInfo', None) if the_section_info is None: return new_sections = json.loads(the_section_info) # build a new list of sections. Make sure the sections are actually in the band. new_section_list = [] for n in new_sections: if n[1] == "": # this is a new section ns = band.new_section(the_band.key, string.replace(string.replace(n[0],"'",""),'"','')) ns.put() s = ns.key else: s = band.section_key_from_urlsafe(n[1]) old_section = s.get() if old_section.name != n[0]: old_section.name=string.replace(string.replace(n[0],"'",""),'"','') old_section.put() new_section_list.append(s) the_band.sections = new_section_list the_band.put() deleted_section_info = self.request.get('deletedSections', None) if deleted_section_info: the_deleted_sections = json.loads(deleted_section_info) if the_deleted_sections: section_keys_to_delete = [band.section_key_from_urlsafe(x) for x in the_deleted_sections] for d in section_keys_to_delete: band.delete_section_key(d) band.set_section_indices(the_band) return
def post(self): the_band_keyurl=self.request.get('bk','0') response_val = [] if the_band_keyurl=='0': pass else: the_band_key = band.band_key_from_urlsafe(the_band_keyurl) the_member_keys = assoc.get_member_keys_of_band_key(the_band_key) response_val = [ [x.get().name, x.urlsafe()] for x in the_member_keys ] self.response.write(json.dumps(response_val))
def get(self): the_user = self.user the_band_keyurl = self.request.get('bk', '0') the_band_key = band.band_key_from_urlsafe(the_band_keyurl) if not is_authorized_to_edit_band(the_band_key, the_user): raise gigoexceptions.GigoException( 'user {0} trying to download users for band {1}'.format( self.user.key.urlsafe(), the_band_key.urlsafe())) self.response.headers['Content-Type'] = 'application/x-gzip' self.response.headers[ 'Content-Disposition'] = 'attachment; filename=members.csv' the_assocs = assoc.get_assocs_of_band_key(the_band_key) the_member_keys = [a.member for a in the_assocs] the_members = member.get_member(the_member_keys) section_keys = band.get_section_keys_of_band_key(the_band_key) sections = band.get_sections_from_keys(section_keys) section_map = {} for s in sections: section_map[s.key] = s.name member_section_map = {} member_data = {} for a in the_assocs: if a.default_section: section = section_map[a.default_section] else: section = '' if a.created: datestr = a.created.strftime('%m/%Y') else: datestr = '' member_data[a.member] = [section, datestr, a.commitment_number] data = "name,nickname,email,phone,section,joined,attended" for m in the_members: nick = m.nickname if m.nickname is None: nick = '' memdat = member_data[m.key] data = u"{0}\n{1},{2},{3},{4},{5},{6},{7}".format( data, m.name, nick, m.email_address, m.phone, memdat[0], memdat[1], memdat[2]) self.response.write(data)
def post(self): the_user = self.user the_band_keyurl = self.request.get('bk',None) the_message = self.request.get('msg', '').strip() if the_message is None or the_message == '': the_message = "(no message)" if the_band_keyurl: the_band = band.get_band(band.band_key_from_urlsafe(the_band_keyurl)) else: the_band = None goemail.send_new_band_via_invite_email(the_band, the_user, the_message)
def get(self): the_user = self.user the_band_keyurl = self.request.get('bk', '0') the_band_key = band.band_key_from_urlsafe(the_band_keyurl) if not is_authorized_to_edit_band(the_band_key, the_user): raise gigoexceptions.GigoException( 'user {0} trying to reset counts for band {1}'.format( self.user.key.urlsafe(), the_band_key.urlsafe())) assoc.reset_counts_for_band(the_band_key) return self.redirect('/band_info.html?bk={0}'.format(the_band_keyurl))
def get(self, *args, **kwargs): the_band_keyurl = kwargs['bk'] if the_band_keyurl is None: return # figure out what to do else: the_band = band.band_key_from_urlsafe(the_band_keyurl).get() feed = get_feed_for_band_key(the_band.key) self.response.content_type = 'application/rss+xml' self.response.write('{0}\n'.format(feed))
def get(self, *args, **kwargs): the_band_keyurl = kwargs['bk'] if the_band_keyurl is None: return # figure out what to do else: the_band = band.band_key_from_urlsafe(the_band_keyurl).get() feed = get_feed_for_band_key(the_band.key) self.response.content_type = 'application/rss+xml' self.response.write('{0}\n'.format(feed))
def post(self): the_user = self.user the_band_keyurl = self.request.get('bk', None) the_message = self.request.get('msg', '').strip() if the_message is None or the_message == '': the_message = "(no message)" if the_band_keyurl: the_band = band.get_band( band.band_key_from_urlsafe(the_band_keyurl)) else: the_band = None goemail.send_new_band_via_invite_email(the_band, the_user, the_message)
def post(self): the_band_keyurl = self.request.get('bk', '0') response_val = [] if the_band_keyurl == '0': pass else: the_band_key = band.band_key_from_urlsafe(the_band_keyurl) the_member_keys = assoc.get_member_keys_of_band_key(the_band_key) response_val = [[x.get().name, x.urlsafe()] for x in the_member_keys] self.response.write(json.dumps(response_val))
def post(self): """ return the sections for a band """ the_user = self.user the_band_key_str=self.request.get('bk','0') if the_band_key_str=='0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_key_str) the_band = band.get_band(the_band_key) the_section_index_str = self.request.get('ski',None) if the_section_index_str is None: the_section is None else: if the_section_index_str == 'None': the_section = None the_section_key = None else: the_section_key = the_band.sections[int(the_section_index_str)] the_section = the_section_key.get() the_assocs = assoc.get_assocs_of_band_key_for_section_key(the_band_key, the_section_key) if the_section is None and len(the_assocs)==0: self.response.write("None") return member_keys = [a.member for a in the_assocs] the_members = member.get_member(member_keys) # make sure members and assocs are in the right order the_members = sorted(the_members, key=lambda m: member_keys.index(m.key)) someone_is_new = False the_user_is_band_admin = assoc.get_admin_status_for_member_for_band_key(the_user, the_band_key) template_args = { 'the_band' : the_band, 'the_section' : the_section, 'the_assocs' : the_assocs, 'the_members' : the_members, 'has_sections' : the_band.sections and len(the_band.sections) > 0, 'the_user_is_band_admin' : the_user_is_band_admin, 'someone_is_new' : someone_is_new } self.render_template('band_sections.html', template_args)
def post(self): """ return the members for a band """ the_user = self.user the_band_key_str=self.request.get('bk','0') if the_band_key_str == '0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_key_str) assocs = assoc.get_assocs_of_band_key(the_band_key=the_band_key, confirmed_only=True) the_members = member.get_member([a.member for a in assocs]) the_members = sorted(the_members,key=lambda member: member.lower_name) # now sort the assocs to be in the same order as the member list assocs = sorted(assocs,key=lambda a: [m.key for m in the_members].index(a.member)) assoc_info=[] the_user_is_band_admin = False for i in range(0,len(assocs)): a=assocs[i] m=the_members[i] if a.default_section: s = a.default_section.get().name else: s = None assoc_info.append( {'name':(m.nickname if m.nickname else m.name), 'is_confirmed':a.is_confirmed, 'is_band_admin':a.is_band_admin, 'is_occasional':a.is_occasional, 'member_key':a.member, 'section':s, 'is_multisectional':a.is_multisectional, 'assoc':a} ) if a.member == the_user.key: the_user_is_band_admin = a.is_band_admin the_section_keys = band.get_band(the_band_key).sections the_sections = band.get_sections_from_keys(the_section_keys) template_args = { 'the_band_key' : the_band_key, 'the_assocs' : assoc_info, 'the_sections' : the_sections, 'the_user_is_band_admin' : the_user_is_band_admin, } self.render_template('band_members.html', template_args)
def get(self): """ post handler - wants a bk """ the_band_keyurl = self.request.get('bk', '0') if the_band_keyurl == '0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_keyurl) the_user = self.user # todo - make sure the user is a superuser if (the_user.is_superuser): band.forget_band_from_key(the_band_key) return self.redirect('/band_admin')
def get(self): the_user = self.user the_band_keyurl=self.request.get('bk','0') the_band_key = band.band_key_from_urlsafe(the_band_keyurl) self.response.headers['Content-Type'] = 'application/x-gzip' self.response.headers['Content-Disposition'] = 'attachment; filename=archive.csv' the_band_key_url=self.request.get("bk",None) if the_band_key_url is None: raise gigoexceptions.GigoException('no band key passed to GigArchivePage handler') else: the_band_key = band.band_key_from_urlsafe(the_band_key_url) # make sure this member is actually in the band if assoc.confirm_user_is_member(the_user.key, the_band_key) is None and the_user.is_superuser is not True: raise gigoexceptions.GigoException('user called GigArchivePage handler but is not member') the_band = band.get_band(the_band_key) if the_band is None: raise gigoexceptions.GigoException('GigArchivePage handler called without a band') the_gigs = gig.get_gigs_for_band_keys(the_band_key, show_past=True) data="date,name,status,committed,pay" for g in the_gigs: plans = plan.get_plans_for_gig_key(g.key, keys_only=True, plan_values=[1,2]) # num=len([p for p in plans if p.value in [1,2]]) num = len(plans) stat=0 if (g.status and g.status in [0,1,2]): stat = g.status data=u"{0}\n{1},\"{2}\",{3},{4},\"{5}\"".format(data, member.format_date_for_member(the_user, g.date, 'short'),g.title,gig.Gig.status_names[stat],num,g.paid) self.response.write(data)
def get(self): """ post handler - wants a bk """ the_band_keyurl=self.request.get('bk','0') if the_band_keyurl=='0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_keyurl) the_user = self.user # todo - make sure the user is a superuser if (the_user.is_superuser): band.forget_band_from_key(the_band_key) return self.redirect('/band_admin')
def post(self): """post handler - if we are edited by the template, handle it here and redirect back to info page""" the_user = self.user the_band_key_url=self.request.get("bk",None) if the_band_key_url is None: self.response.write('did not find a band!') return # todo figure out what to do if we didn't find it the_band_key = band.band_key_from_urlsafe(the_band_key_url) if not assoc.get_admin_status_for_member_for_band_key(the_user, the_band_key) and not the_user.is_superuser: return self.redirect('/band_info.html?bk={0}'.format(the_band.key.urlsafe())) return self.redirect('/band_info.html?bk={0}'.format(the_band.key.urlsafe()))
def _make_page(self, the_user): if self.request.get("new", None) is not None: the_gig = None is_new = True the_band_keyurl = self.request.get("bk", None) if the_band_keyurl is None: return # figure out what to do else: the_band = band.band_key_from_urlsafe(the_band_keyurl).get() else: the_gig_key = self.request.get("gk", None) if (the_gig_key is None): return # figure out what to do the_gig = gig.get_gig_from_key( gig.gig_key_from_urlsafe(the_gig_key)) if the_gig is None: self.response.write('did not find a band or gig!') return # todo figure out what to do if we didn't find it is_new = False the_band = the_gig.key.parent().get() # are we authorized to edit this gig? if gig.can_edit_gig(self.user, the_gig, the_band) is False: # logging.error(u'user {0} trying to edit a gig for band {1}'.format(self.user.key.urlsafe(),the_band.key.urlsafe())) raise gigoexceptions.GigoException( 'user {0} trying to edit a gig for band {1}'.format( self.user.key.urlsafe(), the_band.key.urlsafe())) the_dupe = self.request.get("dupe", 0) # don't think we need this... # if is_new: # user_is_band_admin = False # else: # user_is_band_admin = assoc.get_admin_status_for_member_for_band_key(the_user, the_gig.key.parent()) template_args = { 'gig': the_gig, 'the_band': the_band, # 'user_is_band_admin': user_is_band_admin, 'is_dupe': the_dupe, 'newgig_is_active': is_new, 'the_date_formatter': member.format_date_for_member } self.render_template('gig_edit.html', template_args)
def post(self): the_band_keyurl = self.request.get('bk','0') if the_band_keyurl == '0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_keyurl) the_member_keys = assoc.get_member_keys_of_band_key(the_band_key) the_members = member.get_member(the_member_keys) the_public_members = [x for x in the_members if x.preferences and x.preferences.share_profile and x.verified] template_args = { 'the_members': the_public_members } self.render_template('band_public_members.html', template_args)
def post(self): """ post handler - wants an ak and sk """ the_member_keyurl = self.request.get('mk', '0') the_band_keyurl = self.request.get('bk', '0') the_do = self.request.get('do', '') if the_band_keyurl == '0' or the_member_keyurl == '0': raise Exception("Band or member not specified") if the_do == '': return the_band_key = band.band_key_from_urlsafe(the_band_keyurl) the_member_key = member.member_key_from_urlsafe(the_member_keyurl) assoc.set_multi(the_member_key, the_band_key, (the_do == 'true'))
def post(self): """ makes a new assoc for a member """ the_member_key = member.lookup_member_key(self.request) the_band_key=self.request.get('bk','0') if the_band_key=='0': raise Exception("Band not specified") the_member = the_member_key.get() the_band = band.band_key_from_urlsafe(the_band_key).get() if assoc.get_assoc_for_band_key_and_member_key(the_band_key = the_band.key, the_member_key = the_member_key) is None: assoc.new_association(the_member, the_band) goemail.send_new_member_email(the_band,the_member) # since our bands are changing, invalidate the band list in our session self.user.invalidate_member_bandlists(self, the_member.key)
def post(self): """ post handler - wants an ak and sk """ the_member_keyurl=self.request.get('mk','0') the_band_keyurl=self.request.get('bk','0') the_do=self.request.get('do','') if the_band_keyurl=='0' or the_member_keyurl=='0': raise Exception("Band or member not specified") if the_do=='': return the_band_key = band.band_key_from_urlsafe(the_band_keyurl) the_member_key = member.member_key_from_urlsafe(the_member_keyurl) assoc.set_multi(the_member_key, the_band_key, (the_do=='true'))
def post(self): the_band_keyurl=self.request.get('bk','0') if the_band_keyurl=='0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_keyurl) today_date = datetime.datetime.now() the_gigs = gig.get_gigs_for_band_keys(the_band_key, start_date=today_date) the_gigs = [g for g in the_gigs if g.is_confirmed and not g.is_private] template_args = { 'the_gigs' : the_gigs, } self.render_template('band_upcoming.html', template_args)
def post(self): the_band_keyurl = self.request.get('bk', '0') if the_band_keyurl == '0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_keyurl) the_member_keys = assoc.get_member_keys_of_band_key(the_band_key) the_members = member.get_member(the_member_keys) the_public_members = [ x for x in the_members if x.preferences and x.preferences.share_profile and x.verified ] template_args = {'the_members': the_public_members} self.render_template('band_public_members.html', template_args)
def _make_page(self, the_user): if self.request.get("new", None) is not None: the_gig = None is_new = True the_band_keyurl = self.request.get("bk", None) if the_band_keyurl is None: return # figure out what to do else: the_band = band.band_key_from_urlsafe(the_band_keyurl).get() else: the_gig_key = self.request.get("gk", None) if (the_gig_key is None): return # figure out what to do the_gig = gig.get_gig_from_key(gig.gig_key_from_urlsafe(the_gig_key)) if the_gig is None: self.response.write('did not find a band or gig!') return # todo figure out what to do if we didn't find it is_new = False the_band = the_gig.key.parent().get() # are we authorized to edit this gig? if gig.can_edit_gig(self.user, the_gig, the_band) is False: # logging.error(u'user {0} trying to edit a gig for band {1}'.format(self.user.key.urlsafe(),the_band.key.urlsafe())) raise gigoexceptions.GigoException('user {0} trying to edit a gig for band {1}'.format(self.user.key.urlsafe(),the_band.key.urlsafe())) the_dupe = self.request.get("dupe", 0) # don't think we need this... # if is_new: # user_is_band_admin = False # else: # user_is_band_admin = assoc.get_admin_status_for_member_for_band_key(the_user, the_gig.key.parent()) template_args = { 'gig' : the_gig, 'the_band' : the_band, # 'user_is_band_admin': user_is_band_admin, 'is_dupe' : the_dupe, 'newgig_is_active' : is_new, 'the_date_formatter' : member.format_date_for_member } self.render_template('gig_edit.html', template_args)
def post(self): """post handler - if we are edited by the template, handle it here and redirect back to info page""" the_user = self.user the_band_key_url = self.request.get("bk", None) if the_band_key_url is None: self.response.write('did not find a band!') return # todo figure out what to do if we didn't find it the_band_key = band.band_key_from_urlsafe(the_band_key_url) if not assoc.get_admin_status_for_member_for_band_key( the_user, the_band_key) and not the_user.is_superuser: return self.redirect('/band_info.html?bk={0}'.format( the_band.key.urlsafe())) return self.redirect('/band_info.html?bk={0}'.format( the_band.key.urlsafe()))
def post(self): the_band_keyurl = self.request.get('bk', '0') if the_band_keyurl == '0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_keyurl) today_date = datetime.datetime.now() the_gigs = gig.get_gigs_for_band_keys(the_band_key, start_date=today_date) the_gigs = [g for g in the_gigs if g.is_confirmed and not g.is_private] template_args = { 'the_gigs': the_gigs, } self.render_template('band_upcoming.html', template_args)
def make_page(self, the_user): the_band_key_url = self.request.get("bk", None) if the_band_key_url is None: return else: the_band_key = band.band_key_from_urlsafe(the_band_key_url) the_band = band.get_band(the_band_key) if the_band is None: self.response.write('did not find a band!') return # todo figure out what to do if we didn't find it if not assoc.get_admin_status_for_member_for_band_key( the_user, the_band_key) and not the_user.is_superuser: return self.redirect('/band_info.html?bk={0}'.format( the_band.key.urlsafe())) template_args = {'the_band': the_band} self.render_template('band_invite.html', template_args)
def make_page(self, the_user): the_band_key_url=self.request.get("bk",None) if the_band_key_url is None: return else: the_band_key = band.band_key_from_urlsafe(the_band_key_url) the_band = band.get_band(the_band_key) if the_band is None: self.response.write('did not find a band!') return # todo figure out what to do if we didn't find it if not assoc.get_admin_status_for_member_for_band_key(the_user, the_band_key) and not the_user.is_superuser: return self.redirect('/band_info.html?bk={0}'.format(the_band.key.urlsafe())) template_args = { 'the_band' : the_band } self.render_template('band_invite.html', template_args)
def post(self): """ makes a new assoc for a member """ the_member_key = member.lookup_member_key(self.request) the_band_key = self.request.get('bk', '0') if the_band_key == '0': raise Exception("Band not specified") the_member = the_member_key.get() the_band = band.band_key_from_urlsafe(the_band_key).get() if assoc.get_assoc_for_band_key_and_member_key( the_band_key=the_band.key, the_member_key=the_member_key) is None: assoc.new_association(the_member, the_band) goemail.send_new_member_email(the_band, the_member) # since our bands are changing, invalidate the band list in our session self.user.invalidate_member_bandlists(self, the_member.key)
def get(self): the_user = self.user the_band_keyurl=self.request.get('bk','0') the_band_key = band.band_key_from_urlsafe(the_band_keyurl) if not is_authorized_to_edit_band(the_band_key, the_user): raise gigoexceptions.GigoException('user {0} trying to download users for band {1}'.format(self.user.key.urlsafe(),the_band_key.urlsafe())) self.response.headers['Content-Type'] = 'application/x-gzip' self.response.headers['Content-Disposition'] = 'attachment; filename=members.csv' the_assocs = assoc.get_assocs_of_band_key(the_band_key) the_member_keys = [a.member for a in the_assocs] the_members = member.get_member(the_member_keys) section_keys = band.get_section_keys_of_band_key(the_band_key) sections = band.get_sections_from_keys(section_keys) section_map={} for s in sections: section_map[s.key] = s.name member_section_map={} for a in the_assocs: if a.default_section: member_section_map[a.member] = section_map[a.default_section] else: member_section_map[a.member] = '' data="name,nickname,email,phone,section" for m in the_members: nick = m.nickname if m.nickname is None: nick='' sec = member_section_map[m.key] data=u"{0}\n{1},{2},{3},{4},{5}".format(data,m.name,nick,m.email_address,m.phone,sec) self.response.write(data)
def get(self, *args, **kwargs): try: band_id = kwargs["band_id"] the_band_key = band.band_key_from_urlsafe(band_id) except webapp2.HTTPException: raise except: self.abort(404) # are we authorized to see the band? the_assoc = assoc.get_assoc_for_band_key_and_member_key(self.user.key, the_band_key, confirmed_only=False) if the_assoc is None: self.abort(401) try: info = band.rest_band_info(band.get_band(the_assoc.band), the_assoc=the_assoc, include_id=False) except: self.abort(404) return info
def get(self): the_user = self.user the_band_keyurl=self.request.get('bk','0') the_band_key = band.band_key_from_urlsafe(the_band_keyurl) if not is_authorized_to_edit_band(the_band_key, the_user): raise gigoexceptions.GigoException('user {0} trying to download emails for band {1}'.format(self.user.key.urlsafe(),the_band_key.urlsafe())) the_assocs = assoc.get_assocs_of_band_key(the_band_key) the_member_keys = [a.member for a in the_assocs] the_members = member.get_member(the_member_keys) the_emails = [x.email_address for x in the_members if x.email_address is not None] template_args = { 'the_band' : band.get_band(the_band_key), 'the_emails' : ', '.join(the_emails) } self.render_template('band_emails.html', template_args)
def get(self, *args, **kwargs): try: band_id = kwargs["band_id"] the_band_key = band.band_key_from_urlsafe(band_id) except webapp2.HTTPException: raise except: self.abort(404) # are we authorized to see the band? the_assoc = assoc.get_assoc_for_band_key_and_member_key(self.user.key, the_band_key, confirmed_only=False) if the_assoc is None: self.abort(401) the_assocs = assoc.get_confirmed_assocs_of_band_key(the_band_key, include_occasional=True) member_keys = [a.member for a in the_assocs] members = member.get_member(member_keys) info = [member.rest_member_info(m, True) for m in members] return info
def get(self, *args, **kwargs): try: band_id = kwargs["band_id"] the_band_key = band.band_key_from_urlsafe(band_id) except webapp2.HTTPException: raise except: self.abort(404) # are we authorized to see the band? the_assoc = assoc.get_assoc_for_band_key_and_member_key( self.user.key, the_band_key, confirmed_only=False) if the_assoc is None: self.abort(401) try: info = band.rest_band_info(band.get_band(the_assoc.band), the_assoc=the_assoc, include_id=False) except: self.abort(404) return info
def get(self, *args, **kwargs): try: band_id = kwargs["band_id"] the_band_key = band.band_key_from_urlsafe(band_id) except webapp2.HTTPException: raise except: self.abort(404) # are we authorized to see the band? the_assoc = assoc.get_assoc_for_band_key_and_member_key( self.user.key, the_band_key, confirmed_only=False) if the_assoc is None: self.abort(401) the_assocs = assoc.get_confirmed_assocs_of_band_key( the_band_key, include_occasional=True) member_keys = [a.member for a in the_assocs] members = member.get_member(member_keys) info = [member.rest_member_info(m, True) for m in members] return info
def get(self): the_user = self.user the_band_keyurl = self.request.get('bk', '0') the_band_key = band.band_key_from_urlsafe(the_band_keyurl) if not is_authorized_to_edit_band(the_band_key, the_user): raise gigoexceptions.GigoException( 'user {0} trying to download emails for band {1}'.format( self.user.key.urlsafe(), the_band_key.urlsafe())) the_assocs = assoc.get_assocs_of_band_key(the_band_key) the_member_keys = [a.member for a in the_assocs] the_members = member.get_member(the_member_keys) the_emails = [ x.email_address for x in the_members if x.email_address is not None ] template_args = { 'the_band': band.get_band(the_band_key), 'the_emails': ', '.join(the_emails) } self.render_template('band_emails.html', template_args)
def get(self): """ post handler - wants an ak """ the_user = self.user the_member_keyurl=self.request.get('mk','0') the_band_keyurl=self.request.get('bk','0') if the_member_keyurl=='0' or the_band_keyurl=='0': return # todo figure out what to do the_member_key = member.member_key_from_urlsafe(the_member_keyurl) the_band_key = band.band_key_from_urlsafe(the_band_keyurl) if not is_authorized_to_edit_band(the_band_key,the_user): return # find the association between band and member the_assoc=assoc.get_assoc_for_band_key_and_member_key(the_member_key, the_band_key) assoc.delete_association_from_key(the_assoc.key) gig.reset_gigs_for_contact_key(the_member_key, the_band_key) return self.redirect('/band_info.html?bk={0}'.format(the_band_keyurl))
def make_page(self, the_user): # make sure I'm an admin or a superuser the_user_is_superuser = member.member_is_superuser(the_user) if self.request.get("new", None) is not None: # creating a new band if not the_user_is_superuser: return self.redirect('/') the_band = None is_new = True else: is_new = False the_band_key_str = self.request.get("bk", '0') if the_band_key_str == '0': return else: the_band_key = band.band_key_from_urlsafe(the_band_key_str) the_user_admin_status = assoc.get_admin_status_for_member_for_band_key( the_user, the_band_key) if not the_user_admin_status and not the_user_is_superuser: return self.redirect('/') the_band = band.get_band(the_band_key) if the_band is None: self.response.write('did not find a band!') return # todo figure out what to do if we didn't find it template_args = { 'the_band': the_band, 'timezones': pytz.common_timezones, 'newmember_is_active': is_new, 'is_new': is_new } self.render_template('band_edit.html', template_args)
def get(self): """ post handler - wants an ak """ the_user = self.user the_member_keyurl = self.request.get('mk', '0') the_band_keyurl = self.request.get('bk', '0') if the_member_keyurl == '0' or the_band_keyurl == '0': return # todo figure out what to do the_member_key = member.member_key_from_urlsafe(the_member_keyurl) the_band_key = band.band_key_from_urlsafe(the_band_keyurl) if not is_authorized_to_edit_band(the_band_key, the_user): return # find the association between band and member the_assoc = assoc.get_assoc_for_band_key_and_member_key( the_member_key, the_band_key) assoc.delete_association_from_key(the_assoc.key) gig.reset_gigs_for_contact_key(the_member_key, the_band_key) return self.redirect('/band_info.html?bk={0}'.format(the_band_keyurl))
def make_page(self, the_user): # make sure I'm an admin or a superuser the_user_is_superuser = member.member_is_superuser(the_user) if self.request.get("new",None) is not None: # creating a new band if not the_user_is_superuser: return self.redirect('/') the_band=None is_new=True else: is_new=False the_band_key_str=self.request.get("bk", '0') if the_band_key_str == '0': return else: the_band_key = band.band_key_from_urlsafe(the_band_key_str) the_user_admin_status = assoc.get_admin_status_for_member_for_band_key(the_user, the_band_key) if not the_user_admin_status and not the_user_is_superuser: return self.redirect('/') the_band = band.get_band(the_band_key) if the_band is None: self.response.write('did not find a band!') return # todo figure out what to do if we didn't find it template_args = { 'the_band': the_band, 'timezones': pytz.common_timezones, 'newmember_is_active': is_new, 'is_new': is_new } self.render_template('band_edit.html', template_args)
def make_page(self, the_user): the_band_key_url=self.request.get("bk",None) if the_band_key_url is None: raise gigoexceptions.GigoException('no band key passed to GigTrashcanPage handler') else: the_band_key = band.band_key_from_urlsafe(the_band_key_url) # make sure this member is actually a band admin if not assoc.get_admin_status_for_member_for_band_key(the_user, the_band_key) and not the_user.is_superuser: raise gigoexceptions.GigoException('user called GigTrashcanPage handler but is not admin') the_band = the_band_key.get() if the_band is None: raise gigoexceptions.GigoException('GigTrashcanPage handler calledd without a band') the_gigs = gig.get_trashed_gigs_for_band_key(the_band_key) template_args = { 'the_user' : the_user, 'the_band' : the_band, 'the_gigs' : the_gigs, 'the_date_formatter' : member.format_date_for_member } self.render_template('band_gig_trashcan.html', template_args)
def post(self): """post handler - if we are edited by the template, handle it here and redirect back to info page""" the_gig_key = self.request.get("gk", '0') if (the_gig_key == '0'): the_gig = None else: the_gig = gig.gig_key_from_urlsafe(the_gig_key).get() edit_date_change = False edit_time_change = False edit_status_change = False edit_detail_change = False # first, get the band gig_is_new = False gig_band_keyurl = self.request.get("gig_band", None) if gig_band_keyurl is not None and gig_band_keyurl != '': the_band = band.band_key_from_urlsafe(gig_band_keyurl).get() if the_gig is None: the_gig = gig.new_gig(title="tmp", the_band=the_band, creator=self.user.key) gig_is_new = True # are we authorized to edit a gig for this band? ok_band_list = self.user.get_add_gig_band_list(self, self.user.key) if not the_band.key in [x.key for x in ok_band_list]: logging.error(u'user {0} trying to edit a gig for band {1}'.format(self.user.key.urlsafe(),the_band.key.urlsafe())) return self.redirect('/') # now get the info gig_title = self.request.get("gig_title", None) if gig_title is not None and gig_title != '': the_gig.title = gig_title gig_contact = self.request.get("gig_contact", None) if gig_contact is not None and gig_contact != '': the_gig.contact = member.member_key_from_urlsafe(gig_contact) gig_details = self.request.get("gig_details", None) if gig_details is not None: the_gig.details = gig_details gig_setlist = self.request.get("gig_setlist", None) if gig_setlist is not None: the_gig.setlist = gig_setlist gig_rssdescription = self.request.get("gig_rssdescription", None) if gig_rssdescription is not None: the_gig.rss_description = gig_rssdescription gig_date = self.request.get("gig_date", None) if gig_date is not None and gig_date != '': old_date = the_gig.date the_gig.date = datetime.datetime.combine(babel.dates.parse_date(gig_date,locale=self.user.preferences.locale),datetime.time(0,0,0)) if old_date != the_gig.date: edit_date_change = True # todo validate form entry so date isn't bogus gig_enddate = self.request.get("gig_enddate", None) old_enddate = the_gig.enddate if gig_enddate is not None and gig_enddate != '': the_gig.enddate = datetime.datetime.combine(babel.dates.parse_date(gig_enddate,locale=self.user.preferences.locale),datetime.time(0,0,0)) else: the_gig.enddate = None if old_enddate != the_gig.enddate: edit_date_change = True gig_call = self.request.get("gig_call", '') if gig_call is not None: if the_gig.calltime != gig_call: the_gig.set_calltime(gig_call) edit_time_change = True gig_set = self.request.get("gig_set", '') if gig_set is not None: if the_gig.settime != gig_set: the_gig.set_settime(gig_set) edit_time_change = True gig_end = self.request.get("gig_end", '') if gig_end is not None: if the_gig.endtime != gig_end: the_gig.set_endtime(gig_end) edit_time_change = True gig_address = self.request.get("gig_address", '') if gig_address is not None: the_gig.address = gig_address gig_dress = self.request.get("gig_dress", '') if gig_dress is not None: the_gig.dress = gig_dress gig_paid = self.request.get("gig_paid", '') if gig_paid is not None: the_gig.paid = gig_paid gig_leader = self.request.get("gig_leader", '') if gig_leader is not None: the_gig.leader = gig_leader gig_postgig = self.request.get("gig_postgig", '') if gig_postgig is not None: the_gig.postgig = gig_postgig gig_status = self.request.get("gig_status", '0') old_status = the_gig.status the_gig.status = int(gig_status) if old_status != the_gig.status: edit_status_change = True gig_invite_occasionals=self.request.get("gig_invite_occasionals",None) if (gig_invite_occasionals): the_gig.invite_occasionals = True else: the_gig.invite_occasionals = False gig_hide_from_calendar=self.request.get("gig_hide_from_calendar",None) if (gig_hide_from_calendar): the_gig.hide_from_calendar = True else: the_gig.hide_from_calendar = False gig_private=self.request.get("gig_private",None) if (gig_private): the_gig.is_private = True else: the_gig.is_private = False gig_default_to_attending = self.request.get("default_to_attend",None) if (gig_default_to_attending): logging.info("\n\nattending!\n\n") the_gig.default_to_attending = True the_gig.put() # Is this a series? is_series = self.request.get("newgig_isseries", False) if is_series: number_to_copy = int(self.request.get("newgig_seriescount",1)) - 1 period = self.request.get("newgig_seriesperiod",None) last_date = the_gig.date if period == 'day': delta = datetime.timedelta(days=1) elif period == 'week': delta = datetime.timedelta(weeks=1) else: day_of_month = last_date.day if the_gig.enddate: end_delta = the_gig.enddate - the_gig.date else: end_delta = None newgigs=[] for i in range(0, number_to_copy): copy_gig = clone.clone_entity(the_gig, gig.Gig) if period == 'day' or period == 'week': last_date = last_date + delta else: # figure out what the next month is if last_date.month< 12: mo = last_date.month+1 yr = last_date.year else: mo = 1 yr = last_date.year+1 # figure out last day of next month nextmonth = last_date.replace(month=mo, day=1, year=yr) nextnextmonth = (nextmonth + datetime.timedelta(days=35)).replace(day=1) lastday=(nextnextmonth - datetime.timedelta(days=1)).day if lastday < day_of_month: day_of_gig = lastday else: day_of_gig = day_of_month last_date = last_date.replace(month=mo, day=day_of_gig, year=yr) copy_gig.date = last_date if end_delta is not None: copy_gig.enddate = copy_gig.date + end_delta newgigs.append(copy_gig) if newgigs: ndb.put_multi(newgigs) gig_notify = self.request.get("gig_notifymembers", None) if gig_notify is not None: if gig_is_new: goemail.announce_new_gig(the_gig, self.uri_for('gig_info', _full=True, gk=the_gig.key.urlsafe()), is_edit=False) else: if edit_time_change or edit_date_change or edit_status_change: change_strings=[] if edit_time_change: change_strings.append(_('Time')) if edit_date_change: change_strings.append(_('Date')) if edit_status_change: change_strings.append(_('Status')) change_str = ', '.join(change_strings) else: change_str = _('Details') goemail.announce_new_gig(the_gig, self.uri_for('gig_info', _full=True, gk=the_gig.key.urlsafe()), is_edit=True, change_string=change_str) if (the_band.rss_feed): rss.make_rss_feed_for_band(the_band) band.make_band_cal_dirty(the_band) return self.redirect(\ '/gig_info.html?&gk={0}'.format(the_gig.key.urlsafe()))
def post(self): the_user = self.user the_band_keyurl = self.request.get('bk', '0') if the_band_keyurl == '0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_keyurl) the_band = band.get_band(the_band_key) out = '' if not assoc.get_admin_status_for_member_for_band_key( the_user, the_band_key) and not the_user.is_superuser: out = 'not admin' the_email_blob = self.request.get('e', '') # remove commas and stuff the_email_blob = the_email_blob.replace(',', ' ') the_email_blob = the_email_blob.replace('\n', ' ') the_emails = the_email_blob.split(' ') ok_email = [] not_ok_email = [] for e in the_emails: if e: e = e.lower() if goemail.validate_email(e): ok_email.append(e) else: not_ok_email.append(e) # ok, now we have a list of good email addresses (or, at least, well-formed email addresses # for each one, create a new member (if there isn't one already) for e in ok_email: existing_member = member.get_member_from_email(e) # logging.info("existing_member:{0}".format(existing_member)) if existing_member: # make sure this person isn't already a member of this band; if not, send invite if not assoc.get_associated_status_for_member_for_band_key( existing_member, the_band_key): # create assoc for this member - they're already on the gig-o # send email letting them know they're in the band assoc.new_association(existing_member, the_band, confirm=True) goemail.send_new_band_via_invite_email( the_band, existing_member, the_band.new_member_message) else: # create assoc for this member - but because they're not verified, will just show up as 'invited' # logging.info("creating new member") user_data = member.create_new_member(email=e, name='', password='******') # logging.info("creating new member: {0}".format(user_data)) the_user = user_data[1] if the_user: assoc.new_association(the_user, the_band, confirm=True, invited=True) # send email inviting them to the gig-o token = self.user_model.create_invite_token( the_user.get_id()) verification_url = self.uri_for('inviteverification', type='i', user_id=the_user.get_id(), signup_token=token, _full=True) goemail.send_gigo_invite_email(the_band, the_user, verification_url) # set the new users's locale to be the same as mine by default. if the_user.preferences.locale != self.user.preferences.locale: the_user.preferences.locale = self.user.preferences.locale the_user.put() else: logging.error( "Tried to create new invited member, but failed!") template_args = { 'the_band_keyurl': the_band_keyurl, 'the_ok': ok_email, 'the_not_ok': not_ok_email } self.render_template('band_invite_result.html', template_args)
def post(self): the_user = self.user the_band_keyurl=self.request.get('bk','0') if the_band_keyurl=='0': return # todo figure out what to do the_band_key = band.band_key_from_urlsafe(the_band_keyurl) the_band = band.get_band(the_band_key) out='' if not assoc.get_admin_status_for_member_for_band_key(the_user, the_band_key) and not the_user.is_superuser: out='not admin' the_email_blob = self.request.get('e','') # remove commas and stuff the_email_blob = the_email_blob.replace(',',' ') the_email_blob = the_email_blob.replace('\n',' ') the_emails = the_email_blob.split(' ') ok_email = [] not_ok_email = [] for e in the_emails: if e: e=e.lower() if goemail.validate_email(e): ok_email.append(e) else: not_ok_email.append(e) # ok, now we have a list of good email addresses (or, at least, well-formed email addresses # for each one, create a new member (if there isn't one already) for e in ok_email: existing_member = member.get_member_from_email(e) # logging.info("existing_member:{0}".format(existing_member)) if existing_member: # make sure this person isn't already a member of this band; if not, send invite if not assoc.get_associated_status_for_member_for_band_key(existing_member, the_band_key): # create assoc for this member - they're already on the gig-o # send email letting them know they're in the band assoc.new_association(existing_member, the_band, confirm=True) goemail.send_new_band_via_invite_email(the_band, existing_member, the_band.new_member_message) else: # create assoc for this member - but because they're not verified, will just show up as 'invited' # logging.info("creating new member") user_data = member.create_new_member(email=e, name='', password='******') # logging.info("creating new member: {0}".format(user_data)) the_user = user_data[1] if the_user: assoc.new_association(the_user, the_band, confirm=True, invited=True) # send email inviting them to the gig-o token = self.user_model.create_invite_token(the_user.get_id()) verification_url = self.uri_for('inviteverification', type='i', user_id=the_user.get_id(), signup_token=token, _full=True) goemail.send_gigo_invite_email(the_band, the_user, verification_url) # set the new users's locale to be the same as mine by default. if the_user.preferences.locale != self.user.preferences.locale: the_user.preferences.locale = self.user.preferences.locale the_user.put() else: logging.error("Tried to create new invited member, but failed!") template_args = { 'the_band_keyurl' : the_band_keyurl, 'the_ok' : ok_email, 'the_not_ok' : not_ok_email } self.render_template('band_invite_result.html', template_args)
def post(self): """post handler - if we are edited by the template, handle it here and redirect back to info page""" the_user = self.user the_band_key=self.request.get("bk",'0') if the_band_key=='0': # it's a new band the_band = band.new_band('tmp') else: the_band = band.get_band(band.band_key_from_urlsafe(the_band_key)) if the_band is None: self.response.write('did not find a band!') return # todo figure out what to do if we didn't find it band_name=self.request.get("band_name",None) if band_name is not None and band_name != '': the_band.name=band_name band_shortname=self.request.get("band_shortname",None) if band_shortname is not None: the_band.shortname=band_shortname website=self.request.get("band_website",None) if website[0:7]=='http://': the_band.website = website[7:] else: the_band.website = website new_member_message=self.request.get("new_member_message", None) if new_member_message is not None: the_band.new_member_message = new_member_message.strip() the_band.thumbnail_img=self.request.get("band_thumbnail",None) image_blob = self.request.get("band_images",None) image_split = image_blob.split("\n") image_urls=[] for iu in image_split: the_iu=iu.strip() if the_iu: image_urls.append(the_iu) the_band.images=image_urls member_links_blob = self.request.get("band_member_links",None) if member_links_blob is not None: the_band.member_links=member_links_blob the_band.hometown=self.request.get("band_hometown",None) the_band.description=self.request.get("band_description",None) create_gigs=self.request.get("band_anyonecancreategigs",None) if (create_gigs): the_band.anyone_can_create_gigs = True else: the_band.anyone_can_create_gigs = False manage_gigs=self.request.get("band_anyonecanmanagegigs",None) if (manage_gigs): the_band.anyone_can_manage_gigs = True else: the_band.anyone_can_manage_gigs = False share_gigs=self.request.get("band_sharegigs",None) if (share_gigs): the_band.share_gigs = True else: the_band.share_gigs = False send_updates_by_default=self.request.get("band_sendupdatesbydefault",None) if (send_updates_by_default): the_band.send_updates_by_default = True else: the_band.send_updates_by_default = False rss_change = False enable_rss=self.request.get("band_enablerss",None) if (enable_rss): the_band.rss_feed = True rss_change = True else: the_band.rss_feed = False simple_plan=self.request.get("band_simpleplan",None) if (simple_plan): the_band.simple_planning = True else: the_band.simple_planning = False plan_feedback=self.request.get("band_feedback",None) if (plan_feedback is not None): the_band.plan_feedback=plan_feedback band_timezone=self.request.get("band_timezone",None) if band_timezone is not None and band_timezone != '': the_band.timezone=band_timezone the_band.put() if rss_change: rss.make_rss_feed_for_band(the_band) return self.redirect('/band_info.html?bk={0}'.format(the_band.key.urlsafe()))
def post(self): """post handler - if we are edited by the template, handle it here and redirect back to info page""" the_user = self.user the_band_key = self.request.get("bk", '0') if the_band_key == '0': # it's a new band the_band = band.new_band('tmp') else: the_band = band.get_band(band.band_key_from_urlsafe(the_band_key)) if the_band is None: self.response.write('did not find a band!') return # todo figure out what to do if we didn't find it band_name = self.request.get("band_name", None) if band_name is not None and band_name != '': the_band.name = band_name band_shortname = self.request.get("band_shortname", None) if band_shortname is not None: the_band.shortname = band_shortname website = self.request.get("band_website", None) if website[0:7] == 'http://': the_band.website = website[7:] else: the_band.website = website new_member_message = self.request.get("new_member_message", None) if new_member_message is not None: the_band.new_member_message = new_member_message.strip() the_band.thumbnail_img = self.request.get("band_thumbnail", None) image_blob = self.request.get("band_images", None) image_split = image_blob.split("\n") image_urls = [] for iu in image_split: the_iu = iu.strip() if the_iu: image_urls.append(the_iu) the_band.images = image_urls member_links_blob = self.request.get("band_member_links", None) if member_links_blob is not None: the_band.member_links = member_links_blob the_band.hometown = self.request.get("band_hometown", None) the_band.description = self.request.get("band_description", None) create_gigs = self.request.get("band_anyonecancreategigs", None) if (create_gigs): the_band.anyone_can_create_gigs = True else: the_band.anyone_can_create_gigs = False manage_gigs = self.request.get("band_anyonecanmanagegigs", None) if (manage_gigs): the_band.anyone_can_manage_gigs = True else: the_band.anyone_can_manage_gigs = False share_gigs = self.request.get("band_sharegigs", None) if (share_gigs): the_band.share_gigs = True else: the_band.share_gigs = False send_updates_by_default = self.request.get("band_sendupdatesbydefault", None) if (send_updates_by_default): the_band.send_updates_by_default = True else: the_band.send_updates_by_default = False rss_change = False enable_rss = self.request.get("band_enablerss", None) if (enable_rss): the_band.rss_feed = True rss_change = True else: the_band.rss_feed = False simple_plan = self.request.get("band_simpleplan", None) if (simple_plan): the_band.simple_planning = True else: the_band.simple_planning = False plan_feedback = self.request.get("band_feedback", None) if (plan_feedback is not None): the_band.plan_feedback = plan_feedback band_timezone = self.request.get("band_timezone", None) if band_timezone is not None and band_timezone != '': the_band.timezone = band_timezone the_band.put() if rss_change: rss.make_rss_feed_for_band(the_band) return self.redirect('/band_info.html?bk={0}'.format( the_band.key.urlsafe()))
def _make_page(self, the_user, the_band=None): """ produce the info page """ # find the band we're interested in if the_band is None: band_key_str = self.request.get("bk", None) if band_key_str is None: self.response.write('no band key passed in!') return # todo figure out what to do if there's no ID passed in the_band_key = band.band_key_from_urlsafe(band_key_str) the_band = band.get_band(the_band_key) if the_band is None: self.response.write('did not find a band!') return # todo figure out what to do if we didn't find it if the_user is None: the_user_is_associated = False the_user_is_confirmed = False the_user_admin_status = False the_user_is_superuser = False else: the_user_is_associated = assoc.get_associated_status_for_member_for_band_key( the_user, the_band_key) the_user_is_confirmed = assoc.get_confirmed_status_for_member_for_band_key( the_user, the_band_key) the_user_admin_status = assoc.get_admin_status_for_member_for_band_key( the_user, the_band_key) the_user_is_superuser = member.member_is_superuser(the_user) if the_user_admin_status or the_user_is_superuser: the_pending = assoc.get_pending_members_from_band_key(the_band_key) the_invited_assocs = assoc.get_invited_member_assocs_from_band_key( the_band_key) the_invited = [(x.key, member.get_member(x.member).name) for x in the_invited_assocs] else: the_pending = [] the_invited = [] member_links = None if the_band.member_links: member_links = [] link_list = the_band.member_links.split('\n') for l in link_list: link_info = l.split(':', 1) if len(link_info) == 2: member_links.append( [link_info[0].strip(), link_info[1].strip()]) template_args = { 'the_band': the_band, 'the_user_is_associated': the_user_is_associated, 'the_user_is_confirmed': the_user_is_confirmed, 'the_user_is_band_admin': the_user_admin_status, 'the_pending_members': the_pending, 'the_invited_members': the_invited, 'the_member_links': member_links, 'num_sections': len(the_band.sections) } self.render_template('band_info.html', template_args)