Exemple #1
0
def json_info(user_id):
    user_id = int(user_id)
    user = Zsite.mc_get(user_id)
    namecard = namecard_get(user_id)
    user_info = UserInfo.get(user_id)
    data = {}
    if user_info:
        if user:
            data['cid'] = user.cid
            data['user_id'] = user_id
            data['self_intro'] = user.txt
            data['name'] = user.name
            data['ico'] = ico_url(user_id) or ''
            data['moto'] = motto.get(user_id)
            data['user_link'] = 'http:%s'%user.link
            data['sex'] = user_info.sex
            data['marry'] = user_info.marry
            data['follower_num'] = follow_count_by_to_id(user_id)
            data['following_num'] = follow_count_by_from_id(user_id)
            data['verify_state'] = user.state
            data['pic'] = ico.get(user_id)
            if namecard:
                if namecard.pid_now:
                    data['place_now_name'] = namecard.place_now
                    data['place_now'] = namecard.pid_now
            if user_info.pid_home:
                data['place_home_name'] = user_info.place_home
                data['place_home'] = user_info.pid_home
    return data
Exemple #2
0
def save_user_info(self):
    current_user_id = self.current_user_id

    name = self.get_argument('name', None)
    if name and not name.isdigit():
        zsite_name_edit(current_user_id, name)

    motto = self.get_argument('motto', None)
    if motto:
        _motto.set(current_user_id, motto)

    txt = self.get_argument('txt', '')
    if txt:
        txt_new(current_user_id, txt)

    birthday = self.get_argument('birthday', '0')
    birthday = int(birthday)
    marry = self.get_argument('marry', '')
    pid_home = self.get_argument('pid_home', '1')
    pid_now = self.get_argument('pid_now', '1')
    try:
        pid_now = int(pid_now)
    except ValueError:
        pid_now = 0
    try:
        pid_home = int(pid_home)
    except ValueError:
        pid_home = 0

    marry = int(marry)
    if marry not in (1, 2, 3):
        marry = 0

    o = user_info_new(current_user_id, birthday, marry, pid_home)
    if pid_now:
        c = namecard_get(current_user_id)
        if c:
            c.pid_now = pid_now
            c.save()
        else:
            c = namecard_new(current_user_id, pid_now=pid_now)

    if not o.sex:
        sex = self.get_argument('sex', 0)
        if sex and not o.sex:
            sex = int(sex)
            if sex not in (1, 2):
                sex = 0
            if sex:
                if o:
                    o.sex = sex
                    o.save()
                else:
                    user_info_new(current_user_id, sex=sex)

    search_new(current_user_id)
Exemple #3
0
def save_user_info(self):
    current_user_id = self.current_user_id

    name = self.get_argument("name", None)
    if name and not name.isdigit():
        zsite_name_edit(current_user_id, name)

    motto = self.get_argument("motto", None)
    if motto:
        _motto.set(current_user_id, motto)

    txt = self.get_argument("txt", "")
    if txt:
        txt_new(current_user_id, txt)

    birthday = self.get_argument("birthday", "0")
    birthday = int(birthday)
    marry = self.get_argument("marry", "")
    pid_home = self.get_argument("pid_home", "1")
    pid_now = self.get_argument("pid_now", "1")
    try:
        pid_now = int(pid_now)
    except ValueError:
        pid_now = 0
    try:
        pid_home = int(pid_home)
    except ValueError:
        pid_home = 0

    marry = int(marry)
    if marry not in (1, 2, 3):
        marry = 0

    o = user_info_new(current_user_id, birthday, marry, pid_home)
    if pid_now:
        c = namecard_get(current_user_id)
        if c:
            c.pid_now = pid_now
            c.save()
        else:
            c = namecard_new(current_user_id, pid_now=pid_now)

    if not o.sex:
        sex = self.get_argument("sex", 0)
        if sex and not o.sex:
            sex = int(sex)
            if sex not in (1, 2):
                sex = 0
            if sex:
                if o:
                    o.sex = sex
                    o.save()
                else:
                    user_info_new(current_user_id, sex=sex)

    search_new(current_user_id)
Exemple #4
0
def save_user_info(self):
    current_user_id = self.current_user_id

    name = self.get_argument('name', None)
    if name:
        zsite_name_edit(current_user_id, name)

    motto = self.get_argument('motto', None)
    if motto:
        _motto.set(current_user_id, motto)

    txt = self.get_argument('txt', '')
    if txt:
        txt_new(current_user_id, txt)

    birthday = self.get_argument('birthday', '0')
    birthday = int(birthday)
    marry = self.get_argument('marry', '')
    pid_home = self.get_argument('pid_home', '1')
    pid_now = self.get_argument('pid_now', '1')
    try:
        pid_now = int(pid_now)
    except ValueError:
        pid_now = 0
    try:
        pid_home = int(pid_home)
    except ValueError:
        pid_home = 0

    marry = int(marry)
    if marry not in (1, 2, 3):
        marry = 0

    o = user_info_new(current_user_id, birthday, marry, pid_home)
    if pid_now:
        c = namecard_get(current_user_id)
        if c:
            c.pid_now = pid_now
            c.save()
        else:
            c = namecard_new(current_user_id, pid_now=pid_now)

    if not o.sex:
        sex = self.get_argument('sex', 0)
        if sex and not o.sex:
            sex = int(sex)
            if sex not in (1, 2):
                sex = 0
            if sex:
                if o:
                    o.sex = sex
                    o.save()
                else:
                    user_info_new(current_user_id, sex=sex)

    search_new(current_user_id)
Exemple #5
0
 def get(self):
     current_user = self.current_user
     current_user_id = self.current_user_id
     c = namecard_get(current_user_id) or JsDict()
     self.render(
         name=c.name or current_user.name,
         phone=c.phone,
         mail=c.mail or mail_by_user_id(current_user_id),
         pid_now=c.pid_now or 0,
         address=c.address,
     )
Exemple #6
0
 def get(self):
     current_user = self.current_user
     current_user_id = self.current_user_id
     c = namecard_get(current_user_id) or JsDict()
     self.render(
         name=c.name or current_user.name,
         phone=c.phone,
         mail=c.mail or mail_by_user_id(current_user_id),
         pid_now=c.pid_now or 0,
         address=c.address,
     )
def event_weekly_mail(user, event_city_list, write_mail):
    user_id = user.id
    if mail_notice_state(user_id, CID_MAIL_WEEK):
        mail = mail_by_user_id(user_id)
        #print user_id
        #sys.stdout.flush()
        if mail:
            title = [
            ]
            if not write_mail or not write_mail.title:
                title.append('线下活动 . 周报汇总')
            else:
                title.append('%s ;'%write_mail.title )

            pid = 0
            namecard = namecard_get(user_id)
            if namecard:
                pid_now = namecard.pid_now
                if pid_now:
                    pid = pid_city(pid_now)
            event_city_list, event_incr, place = event_city_info(event_city_list, pid)

            if event_incr:
                title.append(
                    '%s +%s 活动' % (place, event_incr)
                )

            if not write_mail or not write_mail.title:
                title.append(today_cn_date())
                title = ' . '.join(title)
            else:
                title = ' '.join(title)

            name = user.name
            if write_mail and write_mail.txt:
                htm = txt_withlink(write_mail.txt).replace('\r', '</p><p>')
                htm = '<p>%s</p>'%htm
            else:
                htm = None

            #print mail
            #mail = '*****@*****.**'
            #raw_input()

            rendermail(
                '/mail/event/weekly.htm',
                mail,
                name,
                event_city_list=event_city_list,
                write_htm=htm,
                format='html',
                subject=title
            )
Exemple #8
0
def event_weekly_mail(user, event_city_list, write_mail):
    user_id = user.id
    if mail_notice_state(user_id, CID_MAIL_WEEK):
        mail = mail_by_user_id(user_id)
        #print user_id
        #sys.stdout.flush()
        if mail:
            title = []
            if not write_mail or not write_mail.title:
                title.append('线下活动 . 周报汇总')
            else:
                title.append('%s ;' % write_mail.title)

            pid = 0
            namecard = namecard_get(user_id)
            if namecard:
                pid_now = namecard.pid_now
                if pid_now:
                    pid = pid_city(pid_now)
            event_city_list, event_incr, place = event_city_info(
                event_city_list, pid)

            if event_incr:
                title.append('%s +%s 活动' % (place, event_incr))

            if not write_mail or not write_mail.title:
                title.append(today_cn_date())
                title = ' . '.join(title)
            else:
                title = ' '.join(title)

            name = user.name
            if write_mail and write_mail.txt:
                htm = txt_withlink(write_mail.txt).replace('\r', '</p><p>')
                htm = '<p>%s</p>' % htm
            else:
                htm = None

            #print mail
            #mail = '*****@*****.**'
            #raw_input()

            rendermail('/mail/event/weekly.htm',
                       mail,
                       name,
                       event_city_list=event_city_list,
                       write_htm=htm,
                       format='html',
                       subject=title)
Exemple #9
0
    def get(self):
        user_id = self.current_user_id

        if user_id:
            link = '/city/set'
            namecard = namecard_get(user_id)
            if namecard:
                pid_now = namecard.pid_now
                if pid_now:
                    pid = pid_city(pid_now)
                    if pid:
                        link = '/%s' % pid
        else:
            link = '/city/select'

        return self.redirect(link)
Exemple #10
0
    def get(self):
        user_id = self.current_user_id

        if user_id:
            link = '/city/set'
            namecard = namecard_get(user_id)
            if namecard:
                pid_now = namecard.pid_now
                if pid_now:
                    pid = pid_city(pid_now)
                    if pid:
                        link = '/%s'%pid
        else:
            link = '/city/select'

        return self.redirect(link)
Exemple #11
0
 def get(self):
     current_user_id = self.current_user_id
     current_user = self.current_user
     motto = _motto.get(current_user_id)
     txt = txt_get(current_user_id)
     o = UserInfo.mc_get(current_user_id) or JsDict()
     c = namecard_get(current_user_id) or JsDict()
     self.render(
         name=current_user.name,
         motto=motto,
         txt=txt,
         birthday='%08d' % (o.birthday or 0),
         marry=o.marry,
         pid_home=o.pid_home or 0,
         pid_now=c.pid_now or 0,
         sex=o.sex
     )
Exemple #12
0
    def post(self, id, user_id):
        book, booklib = self._fetch(id, user_id)

        zsite = Zsite.mc_get(user_id)
        namecard = namecard_get(user_id)
        zsite_name = self.get_argument('zsite_name', '')
        name = self.get_argument('name', '')
        phone = self.get_argument('phone', '')
        days = self.get_argument('days', '1')

        if zsite_name:
            zsite.name = zsite_name
            zsite.save()
        if phone:
            namecard.phone = phone
        if name:
            namecard.name = name
        if days and days.isdigit():
            days = int(days)
            zsite_book_lib_browse(id, user_id, days, self.current_user_id)

        namecard.save()
        self.redirect("/book/lib/%s" % id)
    def post(self, id, user_id):
        book, booklib = self._fetch(id, user_id)
             
        zsite = Zsite.mc_get(user_id)
        namecard = namecard_get(user_id)
        zsite_name = self.get_argument('zsite_name','')
        name = self.get_argument('name','')
        phone = self.get_argument('phone','')
        days = self.get_argument('days','1')

        if zsite_name:
            zsite.name = zsite_name
            zsite.save()
        if phone:
            namecard.phone = phone
        if name:
            namecard.name = name
        if days and days.isdigit():
            days = int(days)
            zsite_book_lib_browse(id, user_id, days, self.current_user_id)

        namecard.save()
        self.redirect("/book/lib/%s"%id)
Exemple #14
0
 def get(self):
     current_user_id = self.current_user_id
     c = namecard_get(current_user_id) or JsDict()
     self.render(pid_now=c.pid_now or 0)
Exemple #15
0
 def get(self):
     current_user_id = self.current_user_id
     c = namecard_get(current_user_id) or JsDict()
     self.render(pid_now=c.pid_now or 0)