Exemple #1
0
    def verify_user(self):
        if users.get_current_user():
            self.url = users.create_logout_url("/")
            self.url_linktext = "Logout"
        else:
            self.url = users.create_login_url("/")
            self.url_linktext = "Login"
            raise SOSException("You must login")

        user = users.get_current_user()
        email = user.email()
        self.email = email
        users_query = UsersData.all()
        users_query.filter("email = ", email)
        g_us = users_query.fetch(1)

        if len(g_us) < 1:
            logging.error("trying lower case %s" % (email))
            email = email.lower()
            users_query.filter("email = ", email)
            g_us = users_query.fetch(1)

        if len(g_us) < 1:
            error_msg = (
                "You are not authorized to use this service.  You are currently logged into google as: |%s|.  Please verify that this is the user name known to SOS farms"
                % (email)
            )
            logging.error(error_msg)
            raise SOSException(error_msg)

        self.sos_user = g_us[0]
        self.google_user = user
Exemple #2
0
    def post(self):
        try:
            self.verify_admin()

            button_type = self.request.get('button')

            all = False
            if button_type == "Nuke":
                all = True

            if button_type == "UserChoices" or all == True:
                query = UserChoices.all()
                self.nuke_query(query)
            if button_type == "UserData" or all == True:
                query = UsersData.all()
                self.nuke_query(query)
            if button_type == "UserWaitingList" or all == True:
#                query = UsersWaitingList.all()
#                self.nuke_query(query)
                self.convert_wait()
            if button_type == "InventoryList" or all == True:
                query = InventoryList.all()
                self.nuke_query(query)
            if button_type == "Item" or all == True:
                query = Item.all()
                self.nuke_query(query)
            self.do_page()
        except Exception, ex:
            self.error_write(ex)
Exemple #3
0
    def verify_user(self):
        if users.get_current_user():
            self.url = users.create_logout_url("/")
            self.url_linktext = 'Logout'
        else:
            self.url = users.create_login_url("/")
            self.url_linktext = 'Login'
            raise SOSException("You must login")

        user = users.get_current_user()
        email = user.email()
        self.email = email
        users_query = UsersData.all()
        users_query.filter('email = ', email)
        g_us = users_query.fetch(1)

        if len(g_us) < 1:
            logging.error("trying lower case %s" % (email))
            email = email.lower()
            users_query.filter('email = ', email)
            g_us = users_query.fetch(1)

        if len(g_us) < 1:
            error_msg = "You are not authorized to use this service.  You are currently logged into google as: |%s|.  Please verify that this is the user name known to SOS farms" % (
                email)
            logging.error(error_msg)
            raise SOSException(error_msg)

        self.sos_user = g_us[0]
        self.google_user = user
Exemple #4
0
    def post(self):
        try:
            self.verify_admin()

            button_type = self.request.get('button')

            all = False
            if button_type == "Nuke":
                all = True

            if button_type == "UserChoices" or all == True:
                query = UserChoices.all()
                self.nuke_query(query)
            if button_type == "UserData" or all == True:
                query = UsersData.all()
                self.nuke_query(query)
            if button_type == "UserWaitingList" or all == True:
                #                query = UsersWaitingList.all()
                #                self.nuke_query(query)
                self.convert_wait()
            if button_type == "InventoryList" or all == True:
                query = InventoryList.all()
                self.nuke_query(query)
            if button_type == "Item" or all == True:
                query = Item.all()
                self.nuke_query(query)
            self.do_page()
        except Exception, ex:
            self.error_write(ex)
Exemple #5
0
    def get(self):

        url = None
        url_linktext = None
        try:
            if users.get_current_user():
                url = users.create_logout_url("/")
                url_linktext = 'Logout'

                if users.is_current_user_admin():
                    self.redirect('/admin')
                else:
                    user = users.get_current_user()
                    email = user.email()
                    users_query = UsersData.all()
                    users_query.filter('email = ', email)
                    g_us = users_query.fetch(1)

                    if len(g_us) < 1:
                        error_msg = "You are not authorized to use this service.  You are currently logged into google as: |%s|.  Please verify that this is the user name known to SOS farms" % (
                            email)
                        logging.error(
                            "user |%s| attempted to login and failed" %
                            (email))
                        raise SOSException(error_msg)
                    self.redirect('/choices')
            else:
                url = users.create_login_url("/")
                url_linktext = 'Login'
                raise SOSException("Please login")

        except Exception, ex:
            template_values = {
                'error_msg': str(ex),
                'logout_url': url,
                'url_linktext': url_linktext,
            }

            path = os.path.join(os.path.dirname(__file__), 'error.html')
            self.response.out.write(template.render(path, template_values))
Exemple #6
0
    def get(self):

        url = None
        url_linktext = None
        try:
            if users.get_current_user():
                url = users.create_logout_url("/")
                url_linktext = 'Logout'

                if users.is_current_user_admin():
                    self.redirect('/admin')
                else:
                    user = users.get_current_user()
                    email = user.email()
                    users_query = UsersData.all()
                    users_query.filter('email = ', email)
                    g_us = users_query.fetch(1)

                    if len(g_us) < 1:
                        error_msg = "You are not authorized to use this service.  You are currently logged into google as: |%s|.  Please verify that this is the user name known to SOS farms" % (email)
                        logging.error("user |%s| attempted to login and failed" % (email))
                        raise SOSException(error_msg)
                    self.redirect('/choices')
            else:
                url = users.create_login_url("/")
                url_linktext = 'Login'
                raise SOSException("Please login")


        except Exception, ex:
            template_values = {
              'error_msg': str(ex),
              'logout_url': url,
              'url_linktext': url_linktext,
             }

            path = os.path.join(os.path.dirname(__file__), 'error.html')
            self.response.out.write(template.render(path, template_values))
Exemple #7
0
    def post(self):
   
        try:
            self.verify_admin()
            button_type = self.request.get('button')

            if button_type == "Save":
                e = self.request.get('email').strip()
                a = self.request.get('address')
                p = self.request.get('phone')
                f = self.request.get('firstname')
                l = self.request.get('lastname')
                z = self.request.get('zip')
                c = self.request.get('city')
                id = self.request.get('id')

                users_query = UsersData.all()
                users_query.filter('email = ', e)
                g_us = users_query.fetch(1)

                if g_us != None and len(g_us) > 0 and g_us[0].id != id:
                    raise Exception("The email address: %s is already in use" % (e))

                users_query = UsersData.all()
                users_query.filter('id = ', id)
                g_us = users_query.fetch(1)
                if g_us == None or len(g_us) < 1:
                    user = UsersData(id=str(uuid.uuid1()), email=e)
                else:
                    user = g_us[0] 

                user.email = e
                user.address = a
                user.phone = p
                user.firstname = f
                user.lastname = l
                user.zip = z
                user.city = c
                user.put()
                self.write_out()

            elif button_type == "Edit":
                found = False
                users = self.get_all_users()
                for i in users:
                    v = self.request.get(i.id)
                    if v == "on":
                        found = True
                        ui = i

                if found:
                    template_values = {
                        'user': ui,
                        'logout_url': self.url,
                        'url_linktext': self.url_linktext,
                      }
                    path = os.path.join(os.path.dirname(__file__), 'useredit.html')
                    self.response.out.write(template.render(path, template_values))
                else:
                    self.write_out()

            elif button_type == "New":
                template_values = {
                    'logout_url': self.url,
                    'url_linktext': self.url_linktext,
                  }
                path = os.path.join(os.path.dirname(__file__), 'useredit.html')
                self.response.out.write(template.render(path, template_values))

            elif button_type == "Yes":
                v = self.request.get('id')
                q = UsersData.all()
                q.filter('id = ', v)
                u = q.fetch(1)
                if u != None and len(u) == 1:
                    q = UserChoices.all()
                    q.filter('user ='******'user ='******'t done anything just delete it
                        if ucs == None or len(ucs) == 0:
                            i.delete()
                            self.write_out()
                        else:
                        # if it has write out the right page
                            sure_msg = "Are you sure you want to delete this user and all of its purchase order history?"
                            template_values = {
                              'sos_sure_action': '/users',
                              'logout_url': self.url,
                              'ARE_YOU_SURE': sure_msg,
                              'id': i.id,
                              'url_linktext': self.url_linktext,
                             }
                            path = os.path.join(os.path.dirname(__file__), 'sure.html')
                            self.response.out.write(template.render(path, template_values))

                        return


            elif button_type == "Printable":
                self.write_out(fname="userprintable.html")
            elif button_type == "CSV":
                self.write_out(fname="usercsv.html")

        except Exception, ex:
            self.error_write(ex)
            raise
Exemple #8
0
 def get_all_users(self):
     users_query = UsersData.all()
     users_query.order('lastname')
     users = users_query.fetch(1000)
     return users
Exemple #9
0
 def get_all_users(self):
     users_query = UsersData.all()
     g_us = users_query.fetch(1000)
     return g_us
Exemple #10
0
    def post(self):

        try:
            self.verify_admin()
            button_type = self.request.get('button')

            if button_type == "Save":
                e = self.request.get('email').strip()
                a = self.request.get('address')
                p = self.request.get('phone')
                f = self.request.get('firstname')
                l = self.request.get('lastname')
                z = self.request.get('zip')
                c = self.request.get('city')
                id = self.request.get('id')

                users_query = UsersData.all()
                users_query.filter('email = ', e)
                g_us = users_query.fetch(1)

                if g_us != None and len(g_us) > 0 and g_us[0].id != id:
                    raise Exception("The email address: %s is already in use" %
                                    (e))

                users_query = UsersData.all()
                users_query.filter('id = ', id)
                g_us = users_query.fetch(1)
                if g_us == None or len(g_us) < 1:
                    user = UsersData(id=str(uuid.uuid1()), email=e)
                else:
                    user = g_us[0]

                user.email = e
                user.address = a
                user.phone = p
                user.firstname = f
                user.lastname = l
                user.zip = z
                user.city = c
                user.put()
                self.write_out()

            elif button_type == "Edit":
                found = False
                users = self.get_all_users()
                for i in users:
                    v = self.request.get(i.id)
                    if v == "on":
                        found = True
                        ui = i

                if found:
                    template_values = {
                        'user': ui,
                        'logout_url': self.url,
                        'url_linktext': self.url_linktext,
                    }
                    path = os.path.join(os.path.dirname(__file__),
                                        'useredit.html')
                    self.response.out.write(
                        template.render(path, template_values))
                else:
                    self.write_out()

            elif button_type == "New":
                template_values = {
                    'logout_url': self.url,
                    'url_linktext': self.url_linktext,
                }
                path = os.path.join(os.path.dirname(__file__), 'useredit.html')
                self.response.out.write(template.render(path, template_values))

            elif button_type == "Yes":
                v = self.request.get('id')
                q = UsersData.all()
                q.filter('id = ', v)
                u = q.fetch(1)
                if u != None and len(u) == 1:
                    q = UserChoices.all()
                    q.filter('user ='******'user ='******'t done anything just delete it
                        if ucs == None or len(ucs) == 0:
                            i.delete()
                            self.write_out()
                        else:
                            # if it has write out the right page
                            sure_msg = "Are you sure you want to delete this user and all of its purchase order history?"
                            template_values = {
                                'sos_sure_action': '/users',
                                'logout_url': self.url,
                                'ARE_YOU_SURE': sure_msg,
                                'id': i.id,
                                'url_linktext': self.url_linktext,
                            }
                            path = os.path.join(os.path.dirname(__file__),
                                                'sure.html')
                            self.response.out.write(
                                template.render(path, template_values))

                        return

            elif button_type == "Printable":
                self.write_out(fname="userprintable.html")
            elif button_type == "CSV":
                self.write_out(fname="usercsv.html")

        except Exception, ex:
            self.error_write(ex)
            raise
Exemple #11
0
 def get_all_users(self):
     users_query = UsersData.all()
     users_query.order('lastname')
     users = users_query.fetch(1000)
     return users
Exemple #12
0
 def get_all_users(self):
     users_query = UsersData.all()
     g_us = users_query.fetch(1000)
     return g_us