Example #1
0
    def get(self, *args, **kwargs):

        mk = kwargs['mk']

        the_member_key = ndb.Key(urlsafe=mk)
        the_member = the_member_key.get()

        calfeed = None
        if the_member.cal_feed_dirty is False:
            calfeed = get_calfeed_for_key("m", the_member.key)

        if calfeed is None:
            logging.info("member cal feed is dirty")
            the_member.cal_feed_dirty = False
            the_member.put()

            # construct the calendar feed, since it may have changed lately

            calfeed = u'{0}'.format(make_cal_header(the_member.name))

            the_bands = assoc.get_confirmed_bands_of_member(the_member)

            for a_band in the_bands:
                a_band_name = a_band.shortname if a_band.shortname else a_band.name
                all_gigs = gig.get_gigs_for_band_keys(a_band.key,
                                                      show_past=True)
                for a_gig in all_gigs:
                    if not a_gig.is_canceled and not a_gig.hide_from_calendar:  # and not a_gig.is_archived:
                        the_plan = plan.get_plan_for_member_key_for_gig_key(
                            the_member_key, a_gig.key)
                        if the_plan:
                            # check member preferences
                            # include gig if member wants to see all, or if gig is confirmed
                            if a_gig.is_confirmed or \
                                the_member.preferences.calendar_show_only_confirmed == False:
                                # incude gig if member wants to see all, or if has registered
                                # as maybe or definitely:
                                if (the_plan.value > 0 and the_plan.value <= 3) or \
                                    (the_member.preferences.calendar_show_only_committed == False):
                                    if a_gig.is_confirmed:
                                        confstr = u'CONFIRMED!'
                                    else:
                                        confstr = u'(not confirmed)'
                                    calfeed = u'{0}{1}'.format(calfeed, \
                                        make_event(a_gig, a_band, \
                                        title_format=u'{0}:{{0}} {1}'.format(a_band_name, confstr)))

            calfeed = u'{0}{1}'.format(calfeed, make_cal_footer())
            store_calfeed_for_key("m", the_member.key, calfeed)
        self.response.write(calfeed)
Example #2
0
    def get(self, *args, **kwargs):

        mk = kwargs['mk']

        the_member_key = member.member_key_from_urlsafe(mk)
        the_member = the_member_key.get()
        
        calfeed = None
        if the_member.cal_feed_dirty is False:
            calfeed = get_calfeed_for_key("m",the_member.key)

        if calfeed is None:
            logging.info("member cal feed is dirty")
            the_member.cal_feed_dirty = False
            the_member.put()

            # construct the calendar feed, since it may have changed lately

            calfeed = u'{0}'.format(make_cal_header(the_member.name))

            the_bands = assoc.get_confirmed_bands_of_member(the_member)

            for a_band in the_bands:
                a_band_name = a_band.shortname if a_band.shortname else a_band.name
                all_gigs = gig.get_gigs_for_band_keys(a_band.key, show_past=True)
                for a_gig in all_gigs:
                    if not a_gig.is_canceled and not a_gig.hide_from_calendar: # and not a_gig.is_archived:
                        the_plan = plan.get_plan_for_member_key_for_gig_key(the_member_key, a_gig.key)
                        if the_plan:
                            # check member preferences
                            # include gig if member wants to see all, or if gig is confirmed
                            if a_gig.is_confirmed or \
                                the_member.preferences.calendar_show_only_confirmed == False:
                                # incude gig if member wants to see all, or if has registered
                                # as maybe or definitely:
                                if (the_plan.value > 0 and the_plan.value <= 3) or \
                                    (the_member.preferences.calendar_show_only_committed == False):
                                    if a_gig.is_confirmed:
                                        confstr = u'CONFIRMED!'
                                    else:
                                        confstr = u'(not confirmed)'
                                    calfeed = u'{0}{1}'.format(calfeed, \
                                        make_event(a_gig, a_band, \
                                        title_format=u'{0}:{{0}} {1}'.format(a_band_name, confstr)))

            calfeed = u'{0}{1}'.format(calfeed, make_cal_footer())
            store_calfeed_for_key("m",the_member.key,calfeed)
        self.response.write(calfeed)
Example #3
0
File: caldav.py Project: bklang/GO2
    def get(self, *args, **kwargs):

        mk = kwargs['mk']

        the_member_key = ndb.Key(urlsafe=mk)
        the_member = the_member_key.get()

        limit = datetime.datetime.now() - datetime.timedelta(hours=1)
        if the_member.last_calfetch is not None and the_member.last_calfetch > limit:
            # too often - just return 503
            self.response.headers.add_header("Retry-After", "3600")
            self.error(503)
            return

        the_member.last_calfetch = datetime.datetime.now()
        the_member.put()

        info = u'{0}'.format(make_cal_header(the_member.name))

        the_bands = assoc.get_confirmed_bands_of_member(the_member)

        for a_band in the_bands:
            a_band_name = a_band.shortname if a_band.shortname else a_band.name
            all_gigs = gig.get_gigs_for_band_keys(a_band.key, show_past=True)
            for a_gig in all_gigs:
                if not a_gig.is_canceled and not a_gig.hide_from_calendar:  # and not a_gig.is_archived:
                    the_plan = plan.get_plan_for_member_key_for_gig_key(
                        the_member_key, a_gig.key)
                    if the_plan:
                        # check member preferences
                        # include gig if member wants to see all, or if gig is confirmed
                        if a_gig.is_confirmed or \
                            the_member.preferences.calendar_show_only_confirmed == False:
                            # incude gig if member wants to see all, or if has registered
                            # as maybe or definitely:
                            if (the_plan.value > 0 and the_plan.value <= 3) or \
                                (the_member.preferences.calendar_show_only_committed == False):
                                if a_gig.is_confirmed:
                                    confstr = u'CONFIRMED!'
                                else:
                                    confstr = u'(not confirmed)'
                                info = u'{0}{1}'.format(info, \
                                    make_event(a_gig, a_band, \
                                    title_format=u'{0}:{{0}} {1}'.format(a_band_name, confstr)))

        info = u'{0}{1}'.format(info, make_cal_footer())
        self.response.write(info)
Example #4
0
def get_gigs_for_member_for_dates(the_member, start_date, end_date, get_canceled=True):
    """ return gig objects for the bands of a member """
    the_bands = assoc.get_confirmed_bands_of_member(the_member)

    all_gigs = []
    if len(the_bands) > 0:
        if start_date:
            start_date = adjust_date_for_band(the_bands[0], start_date)

        if end_date:
            end_date = adjust_date_for_band(the_bands[0], end_date)

        for a_band in the_bands:
            all_gigs.extend(get_gigs_for_band_key_for_dates(the_band_key=a_band.key, \
                                                        start_date=start_date, \
                                                        end_date=end_date,
                                                        get_canceled=get_canceled))
    return all_gigs
Example #5
0
def get_gigs_for_member_for_dates(the_member, start_date, end_date, get_canceled=True):
    """ return gig objects for the bands of a member """
    the_bands = assoc.get_confirmed_bands_of_member(the_member)

    all_gigs = []
    if len(the_bands) > 0:
        if start_date:
            start_date = adjust_date_for_band(the_bands[0], start_date)

        if end_date:
            end_date = adjust_date_for_band(the_bands[0], end_date)

        for a_band in the_bands:
            all_gigs.extend(get_gigs_for_band_key_for_dates(the_band_key=a_band.key, \
                                                        start_date=start_date, \
                                                        end_date=end_date,
                                                        get_canceled=get_canceled))
    return all_gigs