Ejemplo n.º 1
0
 def getorCreateCoolUserBySinaUser(self, sina_user):
     cooluserlist = CoolUser.all().filter('sinaid', sina_user.id)
     count = cooluserlist.count()
     isnewuser = False
     if count == 0:
         gender = 0
         if sina_user.gender == 'm':
             gender = 0
         else:
             gender = 1
         if self.checkUserNameExist(sina_user.name, '0'):
             name = sina_user.id
         else:
             name = sina_user.name
         cooluser = CoolUser(sinaid=sina_user.id,
                             name=name,
                             gender=gender,
                             logo=sina_user.profile_image_url)
         cooluser.put()
         UserService().initCoolUserData(cooluser)
         isnewuser = True
     else:
         cooluser = cooluserlist[0]
         isnewuser = False
     return cooluser, isnewuser
Ejemplo n.º 2
0
    def getUserCount(self, filter_dict):
        user_list = CoolUser.all()

        if filter_dict:
            for filter_key in filter_dict.keys():
                user_list = user_list.filter(filter_key, filter_dict[filter_key])

        return user_list.count()
Ejemplo n.º 3
0
    def getUserCount(self, filter_dict):
        user_list = CoolUser.all()

        if filter_dict:
            for filter_key in filter_dict.keys():
                user_list = user_list.filter(filter_key,
                                             filter_dict[filter_key])

        return user_list.count()
Ejemplo n.º 4
0
 def checkUserNameExist(self, name, id):
     user_list = CoolUser.all().filter('name', name)
     if user_list.count() == 0:
         return False
     elif user_list.count() == 1:
         if id and user_list[0].id == id:
             return False
         else:
             return True
     else:
         return True
Ejemplo n.º 5
0
 def checkUserEmailExist(self, email, id):
     user_list = CoolUser.all().filter('email', email)
     if user_list.count() == 0:
         return False
     elif user_list.count() == 1:
         if id and user_list[0].id == id:
             return False
         else:
             return True
     else:
         return True
Ejemplo n.º 6
0
 def checkUserNameExist(self, name, id):
     user_list = CoolUser.all().filter("name", name)
     if user_list.count() == 0:
         return False
     elif user_list.count() == 1:
         if id and user_list[0].id == id:
             return False
         else:
             return True
     else:
         return True
Ejemplo n.º 7
0
 def checkUserEmailExist(self, email, id):
     user_list = CoolUser.all().filter("email", email)
     if user_list.count() == 0:
         return False
     elif user_list.count() == 1:
         if id and user_list[0].id == id:
             return False
         else:
             return True
     else:
         return True
Ejemplo n.º 8
0
 def updateGoogleID(self, user, google_user):
     errormessage = None
     if user:
         user_count = CoolUser.all().filter("googleid", google_user.user_id()).count()
         if user_count == 0:
             user.googleid = google_user.user_id()
             user.put()
         else:
             errormessage = ugettext(
                 "Your google account has been bind to another account, please login with your google account directly"
             )
     else:
         errormessage = ugettext("Your did not login")
     return errormessage
Ejemplo n.º 9
0
 def updateGoogleID(self, user, google_user):
     errormessage = None
     if user:
         user_count = CoolUser.all().filter('googleid',
                                            google_user.user_id()).count()
         if user_count == 0:
             user.googleid = google_user.user_id()
             user.put()
         else:
             errormessage = ugettext(
                 'Your google account has been bind to another account, please login with your google account directly'
             )
     else:
         errormessage = ugettext('Your did not login')
     return errormessage
Ejemplo n.º 10
0
    def getCoolUserList(self, filter_dict, orderby, pagesize, pagecount):
        user_list = CoolUser.all()

        if filter_dict:
            for filter_key in filter_dict.keys():
                user_list = user_list.filter(filter_key, filter_dict[filter_key])

        totalRecords = user_list.count()

        if orderby:
            user_list = user_list.order(orderby)

        if pagesize > 0:
            user_list = user_list.fetch(pagesize, pagesize * (pagecount - 1))

        return user_list, totalRecords
Ejemplo n.º 11
0
    def updateSinaID(self, user, sina_user):
        errormessage = None
        if user:
            user_count = CoolUser.all().filter('sinaid', sina_user.id).count()
            if user_count == 0:
                user.sinaid = sina_user.id
                if user.logo == None:
                    user.logo = sina_user.profile_image_url
                user.put()
            else:
                errormessage = ugettext(
                    'Your sina twitter account has been bind to another account, please login with your sina twitter account directly'
                )
        else:
            errormessage = ugettext('Your did not login')

        return errormessage
Ejemplo n.º 12
0
    def getCoolUserList(self, filter_dict, orderby, pagesize, pagecount):
        user_list = CoolUser.all()

        if filter_dict:
            for filter_key in filter_dict.keys():
                user_list = user_list.filter(filter_key,
                                             filter_dict[filter_key])

        totalRecords = user_list.count()

        if orderby:
            user_list = user_list.order(orderby)

        if pagesize > 0:
            user_list = user_list.fetch(pagesize, pagesize * (pagecount - 1))

        return user_list, totalRecords
Ejemplo n.º 13
0
    def updateSinaID(self, user, sina_user):
        errormessage = None
        if user:
            user_count = CoolUser.all().filter("sinaid", sina_user.id).count()
            if user_count == 0:
                user.sinaid = sina_user.id
                if user.logo == None:
                    user.logo = sina_user.profile_image_url
                user.put()
            else:
                errormessage = ugettext(
                    "Your sina twitter account has been bind to another account, please login with your sina twitter account directly"
                )
        else:
            errormessage = ugettext("Your did not login")

        return errormessage
Ejemplo n.º 14
0
 def getorCreateCoolUserBySinaUser(self, sina_user):
     cooluserlist = CoolUser.all().filter("sinaid", sina_user.id)
     count = cooluserlist.count()
     isnewuser = False
     if count == 0:
         gender = 0
         if sina_user.gender == "m":
             gender = 0
         else:
             gender = 1
         if self.checkUserNameExist(sina_user.name, "0"):
             name = sina_user.id
         else:
             name = sina_user.name
         cooluser = CoolUser(sinaid=sina_user.id, name=name, gender=gender, logo=sina_user.profile_image_url)
         cooluser.put()
         UserService().initCoolUserData(cooluser)
         isnewuser = True
     else:
         cooluser = cooluserlist[0]
         isnewuser = False
     return cooluser, isnewuser
Ejemplo n.º 15
0
    def getorCreateCoolUserByGoogleUser(self, google_user):
        cooluserlist = CoolUser.all().filter("googleid", google_user.user_id())
        count = cooluserlist.count()
        isnewuser = False
        if count == 0:
            if self.checkUserNameExist(google_user.nickname(), "0"):
                name = google_user.user_id()
            else:
                name = google_user.nickname()

            if self.checkUserEmailExist(google_user.email(), "0"):
                email = None
            else:
                email = google_user.email()
            cooluser = CoolUser(googleid=google_user.user_id(), name=name, email=email)
            cooluser.put()
            UserService().initCoolUserData(cooluser)
            isnewuser = True
        else:
            cooluser = cooluserlist[0]
            isnewuser = False
        return cooluser, isnewuser
Ejemplo n.º 16
0
    def getorCreateCoolUserByGoogleUser(self, google_user):
        cooluserlist = CoolUser.all().filter('googleid', google_user.user_id())
        count = cooluserlist.count()
        isnewuser = False
        if count == 0:
            if self.checkUserNameExist(google_user.nickname(), '0'):
                name = google_user.user_id()
            else:
                name = google_user.nickname()

            if self.checkUserEmailExist(google_user.email(), '0'):
                email = None
            else:
                email = google_user.email()
            cooluser = CoolUser(googleid=google_user.user_id(),
                                name=name,
                                email=email)
            cooluser.put()
            UserService().initCoolUserData(cooluser)
            isnewuser = True
        else:
            cooluser = cooluserlist[0]
            isnewuser = False
        return cooluser, isnewuser