示例#1
0
    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))
示例#2
0
    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))
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
    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)
示例#9
0
    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)
示例#10
0
    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)
示例#11
0
    def _make_page(self, the_user):

        # get all the admin members
        all_band_keys = band.get_all_bands(keys_only=True)
        all_admin_keys = []
        for bk in all_band_keys:
            admin_member_keys = assoc.get_admin_members_from_band_key(
                bk, keys_only=True)
            for amk in admin_member_keys:
                if not amk in all_admin_keys:
                    all_admin_keys.append(amk)

        all_admin_members = member.get_member(all_admin_keys)
        all_admin_emails = [a.email_address for a in all_admin_members]

        template_args = {'all_admin_emails': all_admin_emails}
        self.render_template('member_admin.html', template_args)
示例#12
0
 def _make_page(self,the_user):
 
     # get all the admin members
     all_band_keys = band.get_all_bands(keys_only=True)
     all_admin_keys = []
     for bk in all_band_keys:
         admin_member_keys = assoc.get_admin_members_from_band_key(bk, keys_only=True)
         for amk in admin_member_keys:
             if not amk in all_admin_keys:
                 all_admin_keys.append(amk)
                 
     all_admin_members = member.get_member(all_admin_keys)
     all_admin_emails = [a.email_address for a in all_admin_members]
     
     template_args = {
         'all_admin_emails' : all_admin_emails
     }
     self.render_template('member_admin.html', template_args)
示例#13
0
    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)
示例#14
0
    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)
示例#15
0
    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
示例#16
0
    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
示例#17
0
    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)
示例#18
0
    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)