コード例 #1
0
ファイル: band_handlers.py プロジェクト: SecondLiners/GO2
    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)
コード例 #2
0
    def get(self, *args, **kwargs):
        user = None
        user_id = kwargs['user_id']
        signup_token = kwargs['signup_token']
        verification_type = kwargs['type']

        # it should be something more concise like
        # self.auth.get_user_by_token(user_id, signup_token
        # unfortunately the auth interface does not (yet) allow to manipulate
        # signup tokens concisely
        user, ts = self.user_model.get_by_auth_token(int(user_id),
                                                     signup_token, 'email')

        if not user:
            raise gigoexceptions.GigoException(
                'Email verification handler could not find any user with id "{0}" signup token "{1}"'
                .format(user_id, signup_token))

        # store user data in the session
        self.auth.set_session(self.auth.store.user_to_dict(user),
                              remember=True)

        if verification_type == 'e':
            new_email = user.set_email_to_pending()
            # remove signup token, we don't want users to come back with an old link
            self.user_model.delete_email_token(user.get_id(), signup_token)
            template_args = {
                'success': new_email != None,
                'the_email': new_email
            }
            self.render_template('confirm_email_change.html',
                                 params=template_args)
        else:
            raise gigoexceptions.GigoException(
                'Email verification handler: verification type not supported')
コード例 #3
0
ファイル: band_handlers.py プロジェクト: SecondLiners/GO2
    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)
コード例 #4
0
    def post(self):
        mk = self.request.get('mk', None)
        st = self.request.get('st', None)
        password = self.request.get('password')

        if mk is None or st is None:
            raise gigoexceptions.GigoException(
                'invite verification handler: no mk or st')

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

        # store user data in the session
        self.auth.set_session(self.auth.store.user_to_dict(the_member),
                              remember=True)

        #   - invalidate the invite link so they can't use it again
        self.user_model.delete_invite_token(the_member.get_id(), st)

        #   - turn their 'invite' assocs into real assocs
        assoc.confirm_invites_for_member_key(the_member.key)

        the_member.set_password(password)
        the_member.verified = True

        name = self.request.get('member_name', '')
        nickname = self.request.get('member_nickname', '')

        if name != '':
            the_member.name = name
        if nickname != '':
            the_member.nickname = nickname

        the_member.put()

        self.redirect(self.uri_for('home'))
コード例 #5
0
ファイル: band_handlers.py プロジェクト: SecondLiners/GO2
    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)
コード例 #6
0
ファイル: band_handlers.py プロジェクト: SecondLiners/GO2
    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
ファイル: band_handlers.py プロジェクト: SecondLiners/GO2
    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))
コード例 #8
0
ファイル: gig_handlers.py プロジェクト: SecondLiners/GO2
    def get(self):

        user = self.user

        the_gig_key = self.request.get("gk", None)

        if the_gig_key is None:
            raise gigoexceptions.GigoException(
                'deletehandler did not find a gig in the request')
        else:
            the_gig = gig.gig_key_from_urlsafe(the_gig_key).get()
            if the_gig:
                the_gig.trashed_date = datetime.datetime.now()
                the_gig.put()
        return self.redirect('/')
コード例 #9
0
    def get(self, *args, **kwargs):
        user = None
        user_id = kwargs['user_id']
        signup_token = kwargs['signup_token']
        verification_type = kwargs['type']

        # it should be something more concise like
        # self.auth.get_user_by_token(user_id, signup_token
        # unfortunately the auth interface does not (yet) allow to manipulate
        # signup tokens concisely
        user, ts = self.user_model.get_by_auth_token(int(user_id),
                                                     signup_token, 'signup')

        if not user:
            logging.error( \
                'Could not find any user with id "%s" signup token "%s"',
                user_id, signup_token)
            locale = self.request.get('locale', None)
            if locale:
                self.redirect('{0}?locale={1}'.format(
                    self.uri_for('linkerror'), locale))
            else:
                self.redirect(self.uri_for('linkerror'))
            return

        # store user data in the session
        self.auth.set_session(self.auth.store.user_to_dict(user),
                              remember=True)

        if verification_type == 'v':
            # remove signup token, we don't want users to come back with an old link
            self.user_model.delete_signup_token(user.get_id(), signup_token)

            if not user.verified:
                user.verified = True
                user.put()
            self.auth.unset_session()

            #             self.display_message('User email address has been verified. Proceed <a href="/login">here</a>')
            self.redirect(self.uri_for('login'))

        elif verification_type == 'p':
            # supply user to the page
            params = {'user': user, 'token': signup_token}
            self.render_template('resetpassword.html', params=params)
        else:
            raise gigoexceptions.GigoException(
                'verification type not supported')
コード例 #10
0
ファイル: gig_handlers.py プロジェクト: SecondLiners/GO2
    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)
コード例 #11
0
ファイル: gig_handlers.py プロジェクト: SecondLiners/GO2
    def get(self):

        user = self.user

        the_gig_key = self.request.get("gk", None)

        if the_gig_key is None:
            raise gigoexceptions.GigoException(
                'restore did not find a gig in the request')
        else:
            the_gig = gig.gig_key_from_urlsafe(the_gig_key).get()
            if the_gig:
                the_gig.trashed_date = None
                the_gig.put()
        return self.redirect(\
            '/gig_info.html?&gk={0}'.format(the_gig.key.urlsafe()))
コード例 #12
0
    def get(self, *args, **kwargs):
        user = None
        user_id = kwargs['user_id']
        signup_token = kwargs['signup_token']
        verification_type = kwargs['type']

        # it should be something more concise like
        # self.auth.get_user_by_token(user_id, signup_token
        # unfortunately the auth interface does not (yet) allow to manipulate
        # signup tokens concisely
        user, ts = self.user_model.get_by_auth_token(int(user_id),
                                                     signup_token, 'invite')

        if not user:
            logging.error( \
                'Could not find any user with id "%s" invite token "%s"',
                user_id, signup_token)
            locale = self.request.get('locale', None)
            if locale:
                self.redirect('{0}?locale={1}'.format(
                    self.uri_for('linkerror'), locale))
            else:
                self.redirect(self.uri_for('linkerror'))
            return

        if verification_type == 'i':
            # ok, this is a user who has one or more invites pending. They have a user but
            # not a password. We need to do this:
            #   - direct them to a welcome page where they can enter a password
            template_args = {
                'mk': user.key.urlsafe(),
                'st': signup_token,
                'locale': user.preferences.locale
            }
            self.render_template('invite_welcome.html', params=template_args)
        else:
            raise gigoexceptions.GigoException(
                'invite verification handler: verification type not supported')
コード例 #13
0
ファイル: band_handlers.py プロジェクト: SecondLiners/GO2
    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)