def get_url(self):
        appitem = self.appitem_set.first()
        if appitem:
            if self.tag == 'navigation':
                url = 'http://%s/appsite/%s/navigation-list/%s/' % (DOMAIN, appitem.token, self.id)
                return get_weixin_site_url(appitem, url)

            if not self.is_single:
                url = 'http://%s/appsite/%s/article-list/%s/' % (DOMAIN, appitem.token, self.id)
            else:
                articles = self.article_set.all()
                article_count = articles.count()
                albums = self.album_set.all()
                album_count = albums.count()
                if article_count == 1 and album_count == 0:
                    article = articles[0]
                    url = article.get_url()
                elif article_count == 0 and album_count == 1:
                    album = albums[0]
                    url = album.get_url()
                else:
                    url = 'http://%s/appsite/%s/article-list/%s/' % (DOMAIN, appitem.token, self.id)

            return get_weixin_site_url(appitem, url)
        else:
            return ''
 def get_url(self):
     appitem = self.appitem
     if appitem:
         url = 'http://%s/appsite/%s/album-detail/%s/' % (DOMAIN, appitem.token, self.id)
         return get_weixin_site_url(appitem, url)
     else:
         return ''
    def get_url(self):
        appitem = self.get_appitem()
        if appitem:
            if not self.content and self.url:
                return self.url

            if self.tag == 'article':
                url = 'http://%s/appsite/%s/article-detail/%s/' % (DOMAIN, appitem.token, self.id)
                return get_weixin_site_url(appitem, url)
            else:
                return self.url
        else:
            return ''
 def get_url_by_name(self, name, args=(), query_string={}, openid=False):
     try:
         url = reverse(name, args=args)
         if query_string:
             string = ''
             for key in query_string:
                 string += key+'='+str(query_string[key]) + '&'
             url = url + '?' + string.rstrip('&')
     except:
         url = ''
     url = 'http://'+settings.DOMAIN+url
     if openid:
         return get_openid_api_url(self, url) #得到用户openid
     else:
         return get_weixin_site_url(self, url)
 def get_site_url(self):
     '''电商微站首页'''
     url = 'http://%s/appsite/%s/home/' % (DOMAIN, self.token)
     return get_weixin_site_url(self, url)