Esempio 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
Esempio 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()
Esempio 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()
Esempio n. 4
0
 def editCoolUser(self, id, name, gender, email, logo, isreceivemail, pagecount):
     user = CoolUser.get_by_id(int(id))
     if user:
         user.name = name
         user.gender = gender
         user.email = email
         user.logo = logo
         user.isreceivemail = isreceivemail
         user.pagecount = pagecount
         user.put()
Esempio 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
Esempio 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
Esempio n. 7
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
Esempio n. 8
0
 def editCoolUser(self, id, name, gender, email, logo, isreceivemail,
                  pagecount):
     user = CoolUser.get_by_id(int(id))
     if user:
         user.name = name
         user.gender = gender
         user.email = email
         user.logo = logo
         user.isreceivemail = isreceivemail
         user.pagecount = pagecount
         user.put()
Esempio n. 9
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
Esempio n. 10
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
Esempio n. 11
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
Esempio n. 12
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
Esempio n. 13
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
Esempio n. 14
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
Esempio n. 15
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
Esempio n. 16
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
Esempio n. 17
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
Esempio n. 18
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
Esempio n. 19
0
 def getCoolUser(self, id):
     return CoolUser.get_by_id(int(id))
Esempio n. 20
0
 def getRecomUserList(self, user):
     user_list = CoolUser.gql('WHERE __key__ != :1 order by __key__ desc',
                              user.key())
     user_list = user_list.fetch(12, 0)
     return user_list
Esempio n. 21
0
 def getCoolUser(self, id):
     return CoolUser.get_by_id(int(id))
Esempio n. 22
0
 def getUser(self, user):
     if user:
         newuser = CoolUser.get_by_id(int(user.id))
         return newuser
     else:
         return None
Esempio n. 23
0
 def getUser(self, user):
     if user:
         newuser = CoolUser.get_by_id(int(user.id))
         return newuser
     else:
         return None
Esempio n. 24
0
 def getRecomUserList(self, user):
     user_list = CoolUser.gql("WHERE __key__ != :1 order by __key__ desc", user.key())
     user_list = user_list.fetch(12, 0)
     return user_list