Beispiel #1
0
    def test_delete_band(self):
        self._make_test_band()

        all_band_keys = band.get_all_bands(keys_only=True)
        self.assertNotEmpty(all_band_keys)
        self.assertEqual(len(all_band_keys), 1)
        self.assertTrue(isinstance(all_band_keys[0], ndb.Key))

        band.forget_band_from_key(all_band_keys[0])
        all_band_keys = band.get_all_bands(keys_only=True)
        self.assertTrue(len(all_band_keys) == 0)
Beispiel #2
0
    def test_delete_band(self):
        self._make_test_band()

        all_band_keys = band.get_all_bands(keys_only=True)
        self.assertNotEmpty(all_band_keys)
        self.assertEqual(len(all_band_keys), 1)
        self.assertTrue(isinstance(all_band_keys[0], ndb.Key))

        band.forget_band_from_key(all_band_keys[0])
        all_band_keys = band.get_all_bands(keys_only=True)
        self.assertTrue(len(all_band_keys)==0)
Beispiel #3
0
 def make_page(self, the_user):
     the_bands = band.get_all_bands()
 
     template_args = {
         'the_bands' : the_bands,
     }
     self.render_template('band_nav.html', template_args)
Beispiel #4
0
  def get(self):

    bands = []
    for b in band.get_all_bands():
      _band = {
        'key'   : b.key.urlsafe(),
        'anyone_can_manage_gigs' : b.anyone_can_manage_gigs,
        'condensed_name' : b.condensed_name,
        'created' : time.mktime(b.created.timetuple()),
        'description' : b.description,
        'hometown' : b.hometown,
        'lower_name' : b.lower_name,
        'member_links' : b.member_links,
        'name' : b.name,
        'plan_feedback' : b.plan_feedback,
        'share_gigs' : b.share_gigs,
        'shortname' : b.shortname,
        'show_in_nav' : b.show_in_nav,
        'simple_planning' : b.simple_planning,
        'thumbnail_img' : b.thumbnail_img,
        'timezone' : b.timezone,
        'website' : b.website
      }
      bands.append(_band)

    self.response.write(json.dumps(bands))
Beispiel #5
0
    def make_page(self, the_user):
        the_bands = band.get_all_bands()

        template_args = {
            'the_bands': the_bands,
        }
        self.render_template('band_nav.html', template_args)
Beispiel #6
0
def rewrite_all_gigs():
    band_keys = band.get_all_bands(keys_only=True)
    for k in band_keys:
        gig_query = Gig.query(ancestor=k)
        g = gig_query.fetch()
        print("\n\n{} gigs\n\n".format(len(g)))
        ndb.put_multi(g)
Beispiel #7
0
 def _make_page(self,the_user):
 
     # todo make sure the user is a superuser
     
     the_bands = band.get_all_bands()
     
     template_args = {
         'the_bands' : the_bands,
     }
     self.render_template('band_admin.html', template_args)
Beispiel #8
0
    def _make_page(self, the_user):

        # todo make sure the user is a superuser

        the_bands = band.get_all_bands()

        template_args = {
            'the_bands': the_bands,
        }
        self.render_template('band_admin.html', template_args)
Beispiel #9
0
    def get(self):

        the_forums = get_public_forums()
        the_bands = band.get_all_bands()

        template_args = {
            'the_public_forums': the_forums,
            'the_bands': the_bands
        }
        self.render_template('forum_admin.html', template_args)
Beispiel #10
0
    def post(self):    
        """ return the bands for a member """
        the_band_keys=assoc.get_band_keys_of_member_key(the_member_key=member.lookup_member_key(self.request), confirmed_only=False)
                    
        every_band = band.get_all_bands()
        all_bands = [a_band for a_band in every_band if a_band.key not in the_band_keys]

        template_args = {
            'all_bands' : all_bands
        }
        self.render_template('member_band_popup.html', template_args)
Beispiel #11
0
    def post(self):    
        """ return the bands for a member """
        the_band_keys=assoc.get_band_keys_of_member_key(the_member_key=lookup_member_key(self.request), confirmed_only=False)
                    
        every_band = band.get_all_bands()
        all_bands = [a_band for a_band in every_band if a_band.key not in the_band_keys]

        template_args = {
            'all_bands' : all_bands
        }
        self.render_template('member_band_popup.html', template_args)
Beispiel #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)
Beispiel #13
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)
Beispiel #14
0
    def _make_page(self, the_user):

        the_member_keys = member.get_all_members(order=False,
                                                 keys_only=True,
                                                 verified_only=True)

        the_bands = band.get_all_bands()

        stats = []
        inactive_bands = []
        for a_band in the_bands:
            is_band_active = False

            a_stat = get_band_stats(a_band.key, today=False)

            the_count_data = []

            if len(a_stat) > 0:
                s = a_stat[0]
                if s.number_upcoming_gigs > 0:
                    is_band_active = True
                for s in a_stat:
                    print("EMAIL: {0} {1}".format(s.number_emails_sent_today,
                                                  s.number_gigs_created_today))
                    the_count_data.append([
                        s.date.year, s.date.month - 1, s.date.day,
                        s.number_members, s.number_upcoming_gigs,
                        s.number_gigs_created_today, s.number_emails_sent_today
                    ])

                if is_band_active:
                    the_count_data_json = json.dumps(the_count_data)
                    stats.append([a_band, the_count_data_json])
                else:
                    inactive_bands.append(a_band)

        template_args = {
            'the_stats': stats,
            'num_members': len(the_member_keys),
            'num_bands': len(the_bands),
            'num_active_bands': len(the_bands) - len(inactive_bands),
            'inactive_bands': inactive_bands
        }
        self.render_template('stats.html', template_args)
Beispiel #15
0
    def post(self):    
        """ return the bands for a member """
        the_user = self.user

        the_member_key=self.request.get('mk','0')
        
        if the_member_key=='0':
            return # todo figure out what to do
            
        the_member_key=ndb.Key(urlsafe=the_member_key)
        the_band_keys=assoc.get_band_keys_of_member_key(the_member_key=the_member_key, confirmed_only=False)
                    
        every_band = band.get_all_bands()
        all_bands = [a_band for a_band in every_band if a_band.key not in the_band_keys]

        template_args = {
            'all_bands' : all_bands
        }
        self.render_template('member_band_popup.html', template_args)
Beispiel #16
0
    def _make_page(self, the_user):

        the_member_keys = member.get_all_members(order=False,
                                                 keys_only=True,
                                                 verified_only=True)

        the_bands = band.get_all_bands()

        stats = []
        inactive_bands = []
        for a_band in the_bands:
            is_band_active = False

            a_stat = get_band_stats(a_band.key)

            the_count_data = []
            for s in a_stat:
                if s.number_upcoming_gigs > 0:
                    is_band_active = True
                the_count_data.append([
                    s.date.year, s.date.month - 1, s.date.day,
                    s.number_members, s.number_upcoming_gigs
                ])

            if is_band_active:
                the_count_data_json = json.dumps(the_count_data)
                stats.append([a_band, the_count_data_json])
            else:
                inactive_bands.append(a_band)

        template_args = {
            'the_stats': stats,
            'num_members': len(the_member_keys),
            'num_bands': len(the_bands),
            'num_active_bands': len(the_bands) - len(inactive_bands),
            'inactive_bands': inactive_bands
        }
        self.render_template('stats.html', template_args)
Beispiel #17
0
    def _make_page(self,the_user):

        the_member_keys = member.get_all_members(order=False, keys_only=True, verified_only=True)

        the_bands = band.get_all_bands()

        stats=[]
        inactive_bands=[]
        for a_band in the_bands:
            is_band_active=False
                
            a_stat = get_band_stats(a_band.key, today=False)
            
            the_count_data=[]

            if len(a_stat) > 0:
                s = a_stat[0]
                if s.number_upcoming_gigs > 0:
                    is_band_active = True
                for s in a_stat:
                    print("EMAIL: {0} {1}".format(s.number_emails_sent_today,s.number_gigs_created_today))
                    the_count_data.append([s.date.year, s.date.month-1, s.date.day, s.number_members, s.number_upcoming_gigs, s.number_gigs_created_today, s.number_emails_sent_today])

                if is_band_active:
                    the_count_data_json=json.dumps(the_count_data)
                    stats.append([a_band, the_count_data_json])
                else:
                    inactive_bands.append(a_band)
        
        template_args = {
            'the_stats' : stats,
            'num_members' : len(the_member_keys),
            'num_bands' : len(the_bands),
            'num_active_bands' : len(the_bands) - len(inactive_bands),
            'inactive_bands' : inactive_bands
        }
        self.render_template('stats.html', template_args)
Beispiel #18
0
    def _make_page(self,the_user):

        the_member_keys = member.get_all_members(order=False, keys_only=True, verified_only=True)

        the_bands = band.get_all_bands()

        stats=[]    
        for a_band in the_bands:
                
            a_stat = get_band_stats(a_band.key)
            
            the_count_data=[]
            for s in a_stat:
                the_count_data.append([s.date.year, s.date.month-1, s.date.day, s.number_members, s.number_upcoming_gigs])
            the_count_data_json=json.dumps(the_count_data)
            
            stats.append([a_band.name, a_band.key, the_count_data_json])
        
        template_args = {
            'the_stats' : stats,
            'num_members' : len(the_member_keys),
            'num_bands' : len(the_bands)
        }
        self.render_template('stats.html', template_args)
Beispiel #19
0
    def _make_page(self,the_user):
        """ construct page for grid view """
        
        # find the bands this member is associated with
        if not the_user.is_superuser:
            the_assocs = assoc.get_confirmed_assocs_of_member(the_user)
            the_band_keys = [a.band for a in the_assocs]
        else:
            the_band_keys = band.get_all_bands(keys_only=True)
        
        if the_band_keys is None or len(the_band_keys)==0:
            return self.redirect('/member_info.html?mk={0}'.format(the_user.key.urlsafe()))
            
        # find the band we're interested in
        band_key_str=self.request.get("bk", None)
        if band_key_str is None:
            the_band_key = the_band_keys[0]
        else:
            the_band_key = ndb.Key(urlsafe=band_key_str)

        month_str=self.request.get("m",None)
        year_str=self.request.get("y",None)
        if month_str==None or year_str==None:
            start_date = datetime.datetime.now().replace(day=1)
        else:
            delta=0
            delta_str=self.request.get("d",None)
            if delta_str != None:
                delta=int(delta_str)
            year=int(year_str)
            month=int(month_str)
            month=month+delta
            if month>12:
                month = 1
                year = year+1
            if month<1:
                month=12
                year = year-1
            start_date = datetime.datetime(year=year, month=month, day=1)
        
        end_date = start_date
        if (end_date.month < 12):
            end_date = end_date.replace(month = end_date.month + 1, day = 1)
        else:
            end_date = end_date.replace(year = end_date.year + 1, month=1, day=1)

        show_canceled=True
        if the_user.preferences and the_user.preferences.hide_canceled_gigs:
            show_canceled=False

        the_gigs = gig.get_gigs_for_band_key_for_dates(the_band_key, start_date, end_date, get_canceled=show_canceled)
        the_member_assocs = band.get_assocs_of_band_key_by_section_key(the_band_key, include_occasional=False)

        the_plans = {}
        for section in the_member_assocs:
            for an_assoc in section[1]:
                member_key=an_assoc.member
                member_plans = {}
                for a_gig in the_gigs:
                    the_plan = plan.get_plan_for_member_key_for_gig_key(the_member_key=member_key, the_gig_key=a_gig.key)
                    if the_plan is not None:
                        member_plans[a_gig.key] = the_plan.value
                the_plans[member_key] = member_plans
                

        template_args = {
            'all_band_keys' : the_band_keys,
            'the_band_key' : the_band_key,
            'the_member_assocs_by_section' : the_member_assocs,
            'the_month_string' : member.format_date_for_member(the_user, start_date, 'month'),
            'the_month' : start_date.month,
            'the_year' : start_date.year,
            'the_date_formatter' : member.format_date_for_member,
            'the_gigs' : the_gigs,
            'the_plans' : the_plans,
            'grid_is_active' : True
        }
        self.render_template('grid.html', template_args)
Beispiel #20
0
 def get(self):
     the_band_keys = band.get_all_bands(keys_only = True)
     for band_key in the_band_keys:
         make_band_stats(band_key)
Beispiel #21
0
    def _make_page(self, the_user):
        """ construct page for grid view """

        # find the bands this member is associated with
        if not the_user.is_superuser:
            the_assocs = assoc.get_confirmed_assocs_of_member(the_user)
            the_band_keys = [a.band for a in the_assocs]
        else:
            the_band_keys = band.get_all_bands(keys_only=True)

        if the_band_keys is None or len(the_band_keys) == 0:
            return self.redirect('/member_info.html?mk={0}'.format(the_user.key.urlsafe()))

        # find the band we're interested in
        band_key_str = self.request.get("bk", None)
        if band_key_str is None:
            the_band_key = the_band_keys[0]
        else:
            the_band_key = ndb.Key(urlsafe=band_key_str)

        month_str = self.request.get("m", None)
        year_str = self.request.get("y", None)
        if month_str == None or year_str == None:
            start_date = datetime.datetime.now().replace(day=1)
        else:
            delta = 0
            delta_str = self.request.get("d", None)
            if delta_str != None:
                delta = int(delta_str)
            year = int(year_str)
            month = int(month_str)
            month = month + delta
            if month > 12:
                month = 1
                year = year + 1
            if month < 1:
                month = 12
                year = year - 1
            start_date = datetime.datetime(year=year, month=month, day=1)

        end_date = start_date
        if (end_date.month < 12):
            end_date = end_date.replace(month=end_date.month + 1, day=1)
        else:
            end_date = end_date.replace(year=end_date.year + 1, month=1, day=1)

        show_canceled = True
        # if the_user.preferences and the_user.preferences.hide_canceled_gigs:
        #     show_canceled = False

        the_gigs = gig.get_all_gig_dates_for_band(the_band_key)
        gig_date_counts={}
        for g in the_gigs:
            ut = '{0}-{1}'.format(g.date.year, g.date.month)
            if ut in gig_date_counts.keys():
                gig_date_counts[ut] += 1
            else:
                gig_date_counts[ut] = 1

        template_args = {
            'all_band_keys': the_band_keys,
            'the_band_key': the_band_key,
            'the_month_string': member.format_date_for_member(the_user, start_date, 'month'),
            'the_month': start_date.month,
            'the_year': start_date.year,
            'has_gigs': len(the_gigs) > 0,
            'date_counts': gig_date_counts,
            'grid_is_active': True
        }
        self.render_template('grid_new.html', template_args)
Beispiel #22
0
    def _make_page(self, the_user):
        """ construct page for grid view """

        # find the bands this member is associated with
        if not the_user.is_superuser:
            the_assocs = assoc.get_confirmed_assocs_of_member(the_user)
            the_band_keys = [a.band for a in the_assocs]
        else:
            the_band_keys = band.get_all_bands(keys_only=True)

        if the_band_keys is None or len(the_band_keys) == 0:
            return self.redirect('/member_info.html?mk={0}'.format(
                the_user.key.urlsafe()))

        # find the band we're interested in
        band_key_str = self.request.get("bk", None)
        if band_key_str is None:
            the_band_key = the_band_keys[0]
        else:
            the_band_key = ndb.Key(urlsafe=band_key_str)

        month_str = self.request.get("m", None)
        year_str = self.request.get("y", None)
        if month_str == None or year_str == None:
            start_date = datetime.datetime.now().replace(day=1)
        else:
            delta = 0
            delta_str = self.request.get("d", None)
            if delta_str != None:
                delta = int(delta_str)
            year = int(year_str)
            month = int(month_str)
            month = month + delta
            if month > 12:
                month = 1
                year = year + 1
            if month < 1:
                month = 12
                year = year - 1
            start_date = datetime.datetime(year=year, month=month, day=1)

        end_date = start_date
        if (end_date.month < 12):
            end_date = end_date.replace(month=end_date.month + 1, day=1)
        else:
            end_date = end_date.replace(year=end_date.year + 1, month=1, day=1)

        show_canceled = True
        if the_user.preferences and the_user.preferences.hide_canceled_gigs:
            show_canceled = False

        the_gigs = gig.get_gigs_for_band_key_for_dates(
            the_band_key, start_date, end_date, get_canceled=show_canceled)

        all_plans = []
        for g in the_gigs:
            all_plans.append(plan.get_plans_for_gig_key(g.key))

        the_member_assocs = band.get_assocs_of_band_key_by_section_key(
            the_band_key, include_occasional=False)

        the_plans = {}
        for section in the_member_assocs:
            for an_assoc in section[1]:
                member_key = an_assoc.member
                member_plans = {}
                for i in range(0, len(the_gigs)):
                    gig_plans = all_plans[i]
                    for p in gig_plans:
                        if p.member == member_key:
                            member_plans[p.key.parent()] = p.value
                            break
                the_plans[member_key] = member_plans

        # the_plans = {}
        # for section in the_member_assocs:
        #     for an_assoc in section[1]:
        #         member_key=an_assoc.member
        #         member_plans = {}
        #         for a_gig in the_gigs:
        #             the_plan = plan.get_plan_for_member_key_for_gig_key(the_member_key=member_key, the_gig_key=a_gig.key, keys_only=True)
        #             if the_plan is not None:
        #                 member_plans[a_gig.key] = the_plan.get().value
        #         the_plans[member_key] = member_plans

        template_args = {
            'all_band_keys':
            the_band_keys,
            'the_band_key':
            the_band_key,
            'the_member_assocs_by_section':
            the_member_assocs,
            'the_month_string':
            member.format_date_for_member(the_user, start_date, 'month'),
            'the_month':
            start_date.month,
            'the_year':
            start_date.year,
            'the_date_formatter':
            member.format_date_for_member,
            'the_gigs':
            the_gigs,
            'the_plans':
            the_plans,
            'grid_is_active':
            True
        }
        self.render_template('grid.html', template_args)
Beispiel #23
0
 def get(self):
     the_band_keys = band.get_all_bands(keys_only=True)
     for band_key in the_band_keys:
         make_band_stats(band_key)