예제 #1
0
    def post(self):

        gig_key_str = self.request.get("gk", None)
        if gig_key_str is None:
            return  # todo figure out what to do if there's no ID passed in
        the_gig = gig.gig_key_from_urlsafe(gig_key_str).get()

        # first, get the old comment text if there is any
        if the_gig.comment_id:
            the_old_comment = gigcomment.get_comment(the_gig.comment_id)
        else:
            the_old_comment = None

        new_comments = comment.get_comments_from_gig_key(the_gig.key)

        the_band = the_gig.key.parent().get()
        for c in new_comments:
            x = c.created_date.replace(tzinfo=pytz.timezone('utc'))
            c.local_date = x.astimezone(pytz.timezone(the_band.timezone))

        template_args = {
            'the_old_comments': the_old_comment,
            'the_comments': new_comments,
            'the_date_formatter': member.format_date_for_member
        }

        self.render_template('comments.html', template_args)
예제 #2
0
파일: gig.py 프로젝트: bklang/GO2
    def post(self):

        gig_key_str = self.request.get("gk", None)
        if gig_key_str is None:
            return  # todo figure out what to do if there's no ID passed in
        the_gig = ndb.Key(urlsafe=gig_key_str).get()

        # first, get the old comment text if there is any
        if the_gig.comment_id:
            the_old_comment = gigcomment.get_comment(the_gig.comment_id)
        else:
            the_old_comment = None

        new_comments = comment.get_comments_from_gig_key(the_gig.key)

        template_args = {
            'the_old_comments': the_old_comment,
            'the_comments': new_comments,
            'the_date_formatter': member.format_date_for_member
        }

        self.render_template('comments.html', template_args)
예제 #3
0
    def post(self):
    
        gig_key_str = self.request.get("gk", None)
        if gig_key_str is None:
            return # todo figure out what to do if there's no ID passed in
        the_gig = gig.gig_key_from_urlsafe(gig_key_str).get()

        # first, get the old comment text if there is any
        if the_gig.comment_id:
            the_old_comment = gigcomment.get_comment(the_gig.comment_id)
        else:
            the_old_comment = None

        new_comments = comment.get_comments_from_gig_key(the_gig.key)
        
        template_args = {
            'the_old_comments' : the_old_comment,
            'the_comments' : new_comments,
            'the_date_formatter' : member.format_date_for_member            
        }
        
        self.render_template('comments.html', template_args)
예제 #4
0
    def _make_page(self, the_user):

        # find the gig we're interested in
        gig_key_str = self.request.get("gk", None)
        if gig_key_str is None:
            self.response.write('no gig key passed in!')
            return  # todo figure out what to do if there's no ID passed in

        gig_key = gig.gig_key_from_urlsafe(gig_key_str)
        the_gig = gig_key.get()

        if the_gig is None:
            template_args = {}
            self.render_template('no_gig_found.html', template_args)
            return  # todo figure out what to do if we didn't find it

        the_comment_text = None
        if the_gig.comment_id:
            the_comment_text = gigcomment.get_comment(the_gig.comment_id)

        if not the_gig.is_archived:

            the_band_key = the_gig.key.parent()
            the_plans, the_plan_counts, the_sections, band_has_sections = _makeInfoPageInfo(
                the_user, the_gig, the_band_key)

            # is the current user a band admin?
            the_user_is_band_admin = assoc.get_admin_status_for_member_for_band_key(
                the_user, the_band_key)
            the_band = the_band_key.get()
            user_can_edit = gig.can_edit_gig(the_user, the_gig, the_band)
            user_can_create = gig.can_edit_gig(the_user, None, the_band)

            datestr = member.format_date_for_member(the_user,
                                                    the_gig.date,
                                                    format="long")
            if the_gig.enddate:
                enddatestr = u' - {0}'.format(
                    member.format_date_for_member(the_user,
                                                  the_gig.enddate,
                                                  format="long"))
            else:
                enddatestr = ''

            if the_gig.address:
                if the_gig.address.startswith('http'):
                    address_link = the_gig.address
                else:
                    address_link = u"http://maps.google.com?q={0}".format(
                        the_gig.address.replace(' ', '+'))
            else:
                address_link = ''

            template_args = {
                'gig': the_gig,
                'date_str': datestr,
                'enddate_str': enddatestr,
                'the_plans': the_plans,
                'the_sections': the_sections,
                'comment_text': the_comment_text,
                'band_has_sections': band_has_sections,
                'the_user_is_band_admin': the_user_is_band_admin,
                'user_can_edit': user_can_edit,
                'user_can_create': user_can_create,
                'the_plan_counts': the_plan_counts,
                'address_link': address_link
            }
            self.render_template('gig_info.html', template_args)

        else:
            # this is an archived gig
            the_archived_plans = gigarchive.get_archived_plans(
                the_gig.archive_id)
            template_args = {
                'gig': the_gig,
                'archived_plans': the_archived_plans,
                'comment_text': the_comment_text
            }
            self.render_template('gig_archived_info.html', template_args)
예제 #5
0
파일: gig.py 프로젝트: bklang/GO2
    def _make_page(self, the_user):

        # find the gig we're interested in
        gig_key_str = self.request.get("gk", None)
        if gig_key_str is None:
            self.response.write('no gig key passed in!')
            return  # todo figure out what to do if there's no ID passed in

        gig_key = ndb.Key(urlsafe=gig_key_str)
        the_gig = gig_key.get()

        if the_gig is None:
            template_args = {}
            self.render_template('no_gig_found.html', template_args)
            return  # todo figure out what to do if we didn't find it

        the_comment_text = None
        if the_gig.comment_id:
            the_comment_text = gigcomment.get_comment(the_gig.comment_id)

        if not the_gig.is_archived:
            the_band_key = the_gig.key.parent()

            the_assocs = assoc.get_assocs_of_band_key(the_band_key,
                                                      confirmed_only=True,
                                                      keys_only=False)

            # get all the plans for this gig - might actually not be any yet.
            all_plans = plan.get_plans_for_gig_key(gig_key, keys_only=False)

            # now, for each associated member, find or make a plan
            the_plans = []
            the_new_plans = []  # in case we need to make new ones

            the_plan_counts = {}
            for i in range(len(plan.plan_text)):
                the_plan_counts[i] = 0

            need_empty_section = False
            for the_assoc in the_assocs:
                a_member_key = the_assoc.member
                new_plan = False

                for p in all_plans:
                    if p.member == a_member_key:
                        the_plan = p
                        break
                else:
                    the_plan = plan.Plan(parent=gig_key,
                                         member=a_member_key,
                                         value=0,
                                         comment="",
                                         section=None)
                    the_new_plans.append(the_plan)
                    new_plan = True

                if (not the_assoc.is_occasional) or \
                   (the_assoc.is_occasional and the_plan.value != 0) or \
                   (a_member_key == the_user.key) or \
                   the_user.is_superuser:
                    if the_plan.section == None and the_assoc.default_section == None:
                        need_empty_section = True
                    info_block = {}
                    info_block['the_gig_key'] = the_gig.key
                    info_block['the_plan'] = the_plan
                    info_block['the_member_key'] = a_member_key
                    info_block['the_band_key'] = the_band_key
                    info_block['the_assoc'] = the_assoc
                    if the_plan.section is not None:
                        info_block['the_section'] = the_plan.section
                    else:
                        info_block['the_section'] = the_assoc.default_section
                    the_plans.append(info_block)
                    the_plan_counts[the_plan.value] += 1

            if the_new_plans:
                ndb.put_multi(the_new_plans)

            the_section_keys = band.get_section_keys_of_band_key(the_band_key)
            the_sections = ndb.get_multi(the_section_keys)
            if need_empty_section:
                the_sections.append(None)

            if len(the_section_keys) == 0:
                band_has_sections = False
            else:
                band_has_sections = True

            # is the current user a band admin?
            the_user_is_band_admin = assoc.get_admin_status_for_member_for_band_key(
                the_user, the_band_key)
            the_band = the_band_key.get()
            user_can_edit = can_edit_gig(the_user, the_gig, the_band)
            user_can_create = can_edit_gig(the_user, None, the_band)

            datestr = member.format_date_for_member(the_user,
                                                    the_gig.date,
                                                    format="long")
            if the_gig.enddate:
                enddatestr = u' - {0}'.format(
                    member.format_date_for_member(the_user,
                                                  the_gig.enddate,
                                                  format="long"))
            else:
                enddatestr = ''

            template_args = {
                'gig': the_gig,
                'date_str': datestr,
                'enddate_str': enddatestr,
                'the_plans': the_plans,
                'the_sections': the_sections,
                'comment_text': the_comment_text,
                'band_has_sections': band_has_sections,
                'the_user_is_band_admin': the_user_is_band_admin,
                'user_can_edit': user_can_edit,
                'user_can_create': user_can_create,
                'the_plan_counts': the_plan_counts
            }
            self.render_template('gig_info.html', template_args)

        else:
            # this is an archived gig
            the_archived_plans = gigarchive.get_archived_plans(
                the_gig.archive_id)
            template_args = {
                'gig': the_gig,
                'archived_plans': the_archived_plans,
                'comment_text': the_comment_text
            }
            self.render_template('gig_archived_info.html', template_args)
예제 #6
0
    def _make_page(self, the_user):

        # find the gig we're interested in
        gig_key_str = self.request.get("gk", None)
        if gig_key_str is None:
            self.response.write('no gig key passed in!')
            return # todo figure out what to do if there's no ID passed in

        gig_key = gig.gig_key_from_urlsafe(gig_key_str)
        the_gig = gig_key.get()

        if the_gig is None:
            template_args = {}
            self.render_template('no_gig_found.html', template_args)
            return # todo figure out what to do if we didn't find it

        the_comment_text = None
        if the_gig.comment_id:
            the_comment_text = gigcomment.get_comment(the_gig.comment_id)

        if not the_gig.is_archived:

            the_band_key = the_gig.key.parent()
            the_plans, the_plan_counts, the_sections, band_has_sections = _makeInfoPageInfo(the_user, the_gig, the_band_key)

            # is the current user a band admin?
            the_user_is_band_admin = assoc.get_admin_status_for_member_for_band_key(the_user, the_band_key)
            the_band = the_band_key.get()
            user_can_edit = gig.can_edit_gig(the_user, the_gig, the_band)
            user_can_create = gig.can_edit_gig(the_user, None, the_band)

            datestr = member.format_date_for_member(the_user, the_gig.date, format="long")
            if the_gig.enddate:
                enddatestr = u' - {0}'.format(member.format_date_for_member(the_user, the_gig.enddate, format="long"))
            else:
                enddatestr = ''

            template_args = {
                'gig' : the_gig,
                'date_str' : datestr,
                'enddate_str' : enddatestr,
                'the_plans' : the_plans,
                'the_sections' : the_sections,
                'comment_text' : the_comment_text,
                'band_has_sections' : band_has_sections,
                'the_user_is_band_admin' : the_user_is_band_admin,
                'user_can_edit' : user_can_edit,
                'user_can_create' : user_can_create,
                'the_plan_counts' : the_plan_counts
            }
            self.render_template('gig_info.html', template_args)

        else:
            # this is an archived gig
            the_archived_plans = gigarchive.get_archived_plans(the_gig.archive_id)
            template_args = {
                'gig' : the_gig,
                'archived_plans' : the_archived_plans,
                'comment_text' : the_comment_text
            }
            self.render_template('gig_archived_info.html', template_args)
예제 #7
0
파일: gig.py 프로젝트: ChaoticNoise/GO2
    def _make_page(self, the_user):

        # find the gig we're interested in
        gig_key_str = self.request.get("gk", None)
        if gig_key_str is None:
            self.response.write('no gig key passed in!')
            return # todo figure out what to do if there's no ID passed in

        gig_key = ndb.Key(urlsafe=gig_key_str)
        the_gig = gig_key.get()

        if the_gig is None:
            template_args = {}
            self.render_template('no_gig_found.html', template_args)
            return # todo figure out what to do if we didn't find it

        the_comment_text = None
        if the_gig.comment_id:
            the_comment_text = gigcomment.get_comment(the_gig.comment_id)
            
        if not the_gig.is_archived:
            the_band_key = the_gig.key.parent()

            the_assocs = assoc.get_assocs_of_band_key(the_band_key, confirmed_only=True, keys_only=False)

            the_plans = []
        
            need_empty_section = False
            for the_assoc in the_assocs:
                a_member_key = the_assoc.member
                the_plan = plan.get_plan_for_member_key_for_gig_key(a_member_key, gig_key)
                if (not the_assoc.is_occasional) or \
                   (the_assoc.is_occasional and the_plan.value != 0) or \
                   (a_member_key == the_user.key) or \
                   the_user.is_superuser:
                    if the_plan.section==None and the_assoc.default_section==None:
                        need_empty_section = True
                    info_block={}
                    info_block['the_gig_key'] = the_gig.key
                    info_block['the_plan_key'] = the_plan.key
                    info_block['the_member_key'] = a_member_key
                    info_block['the_band_key'] = the_band_key
                    info_block['the_assoc'] = the_assoc
                    if the_plan.section is not None:
                        info_block['the_section'] = the_plan.section
                    else:
                        info_block['the_section'] = the_assoc.default_section            
                    the_plans.append(info_block)          
        
            the_section_keys = band.get_section_keys_of_band_key(the_band_key)
            the_sections = ndb.get_multi(the_section_keys)
            if need_empty_section:
                the_sections.append(None)
                
            if len(the_section_keys)==0:
                band_has_sections = False
            else:
                band_has_sections = True

            # is the current user a band admin?
            user_is_band_admin = assoc.get_admin_status_for_member_for_band_key(the_user, the_band_key)

            user_can_edit = False
            if user_is_band_admin or the_user.is_superuser:
                user_can_edit = True
            elif the_band_key.get().anyone_can_manage_gigs:
                user_can_edit = True

            datestr = member.format_date_for_member(the_user, the_gig.date, format="long")
            if the_gig.enddate:
                enddatestr = u' - {0}'.format(member.format_date_for_member(the_user, the_gig.enddate, format="long"))
            else:
                enddatestr = ''

            template_args = {
                'gig' : the_gig,
                'date_str' : datestr,
                'enddate_str' : enddatestr,
                'the_plans' : the_plans,
                'the_sections' : the_sections,
                'comment_text' : the_comment_text,
                'band_has_sections' : band_has_sections,
                'user_is_band_admin' : user_is_band_admin,
                'user_can_edit' : user_can_edit
            }
            self.render_template('gig_info.html', template_args)

        else:
            # this is an archived gig
            the_archived_plans = gigarchive.get_archived_plans(the_gig.archive_id)
            template_args = {
                'gig' : the_gig,
                'archived_plans' : the_archived_plans,
                'comment_text' : the_comment_text
            }
            self.render_template('gig_archived_info.html', template_args)