コード例 #1
0
ファイル: adapters.py プロジェクト: zack-steven-jobs/liuli
 def convert_to(self, from_model):
     result_dict = []
     group_content = get_region_group(from_model)
     if from_model.review_status:
         result_dict.append({
             'id':
             from_model.id,
             'name':
             from_model.name,
             'search_keyword':
             from_model.search_keyword if from_model.search_keyword else '',
             'path':
             from_model.url
             or parse_url(from_model.path.url if from_model.path else ''),
             'start_date':
             datetime2timestamp(from_model.start_date, convert_to_utc=True),
             'end_date':
             datetime2timestamp(from_model.end_date, convert_to_utc=True),
             'is_default':
             from_model.is_default,
             'type':
             from_model.type,
             'attr':
             from_model.attr,
             'region':
             group_content,
             'home_banner':
             from_model.home_banner.strip()
             if from_model.home_banner else '',
         })
     return result_dict
コード例 #2
0
ファイル: adapters.py プロジェクト: liuliainio/liuli
 def convert_to(self, from_model):
     message_infos = {
             'id': from_model.id,
             'message_id': from_model.id + 10000,
             'action': _ACTIONS[from_model.action] if from_model.action in _ACTIONS else 'Notification',
             'value': {
                     'display_area': from_model.display_area,
                     'click_value': _get_click_value(from_model) if from_model.action in _CLICK_ACTION_MAPPING \
                             else _get_message_action_url(from_model),
                     'click_action': 'OpenURL' if from_model.action not in _CLICK_ACTION_MAPPING \
                             else _CLICK_ACTION_MAPPING[from_model.action],
                     'description': from_model.content,
                     'clearable': True,
                     'title': from_model.title,
                     'icon_url': '' if not from_model.icon_url and not from_model.icon_path else \
                             (from_model.icon_url or parse_url(from_model.icon_path.url)),
                 },
             'status': from_model.status,
             'created_time': datetime2timestamp(from_model.created_time, convert_to_utc=True),
             'last_modified': datetime2timestamp(from_model.modified_time, convert_to_utc=True),
             'not_valid_before': datetime2timestamp(from_model.invalid_before, convert_to_utc=True),
             'not_valid_after': datetime2timestamp(from_model.invalid_after, convert_to_utc=True),
             'client_id': from_model.client_id,
             'category': from_model.category or 'N/A',
             'short_message': from_model.short_message or 'N/A',
         }
     if from_model.action == PUSH_MESSAGE_ACTIONS.LAUNCHB:
         message_infos['value'].update(message_infos['value']['click_value'])
         del message_infos['value']['click_value']
     if from_model.extra_infos:
         message_infos['value'].update(simplejson.loads(from_model.extra_infos))
     if from_model.targets:
         message_infos['targets'] = simplejson.loads(from_model.targets)
     return [message_infos]
コード例 #3
0
ファイル: adapters.py プロジェクト: zack-steven-jobs/liuli
 def convert_to(self, from_model):
     subject_item = {
         'id':
         from_model.id,
         'subject_id':
         from_model.subject.id,
         'title':
         from_model.title,
         'description':
         from_model.description,
         'icon_url':
         from_model.icon_url or parse_url(
             from_model.icon_path.url if from_model.icon_path else ''),
         'order':
         from_model.order,
         'subject_info': {
             'name':
             from_model.subject.name,
             'sub_title':
             from_model.subject.sub_title,
             'click_count':
             from_model.subject.clicks_count,
             'description':
             from_model.subject.description,
             'pub_date':
             datetime2timestamp(from_model.subject.pub_date,
                                convert_to_utc=True),
         }
     }
     apps = []
     for subject_app in from_model.apps.all().order_by('order'):
         current_version = subject_app.app.current_version
         reviewed_version = _get_reviewed_version(subject_app.app)
         if current_version:
             app_infos = {
                     'pk': subject_app.id,
                     'order': subject_app.order,
                     'id': subject_app.app.id,
                     'tid': subject_app.app.t_id if (subject_app.app.t_id and subject_app.app.t_status == 1) else 0,
                     'download_tid': subject_app.app.t_id if (subject_app.app.t_id and subject_app.app.t_status == 1 and (current_version.t_status == 6 or subject_app.app.t_chargemode not in (0, 4) or not (current_version.download_url or \
                             parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0,
                     'backup_tid': subject_app.app.t_id if subject_app.app.t_id else 0,
                     'name': subject_app.app.name,
                     'description': reviewed_version.description,
                     'version': current_version.version,
                     'version_code': current_version.version_code,
                     'package_name': subject_app.app.package_name,
                     'price': float(subject_app.app.price),
                     'rate': float(subject_app.app.rate),
                     'icon_url': current_version.icon_url or parse_url(current_version.icon_path.url if current_version.icon_path else ''),
                     'pub_date': datetime2timestamp(current_version.pub_date, convert_to_utc=True),
                     'download_count': subject_app.app.downloads_count,
                     'size': friendly_size(current_version.size),
                     'min_sdk_version': current_version.min_sdk_version,
                 }
             app_infos.update(_convert_app_labels(subject_app.app.label))
             apps.append(app_infos)
     subject_item['apps'] = apps
     return [subject_item]
コード例 #4
0
ファイル: adapters.py プロジェクト: zack-steven-jobs/liuli
 def convert_to(self, from_model):
     result_dict = []
     group_content = get_region_group(from_model)
     if from_model.review_status:
         result_dict.append({
             'id':
             from_model.id,
             'type':
             from_model.type,
             'attr':
             from_model.attr,
             'area':
             from_model.area,
             'order':
             from_model.order,
             'pub_date':
             datetime2timestamp(from_model.pub_date, convert_to_utc=True),
             'icon_url':
             from_model.icon_url or parse_url(
                 from_model.icon_path.url if from_model.icon_path else ''),
             'category_id':
             from_model.category.id if from_model.category else 0,
             'recommend_type':
             from_model.recommend_type,
             'region':
             group_content,
             'cooperate_list_id':
             from_model.cooperate_list_id.strip()
             if from_model.cooperate_list_id else '',
             'cooperate_list_name':
             from_model.cooperate_list_name.strip()
             if from_model.cooperate_list_name else ''
         })
     return result_dict
コード例 #5
0
ファイル: adapters.py プロジェクト: zack-steven-jobs/liuli
 def convert_to(self, from_model):
     result_dict = []
     current_version = from_model.app.current_version
     reviewed_version = _get_reviewed_version(from_model.app)
     if current_version and from_model.app.review_status:
         app_infos = {
                 'pk': from_model.id,
                 'id': from_model.app.id,
                 'tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1) else 0,
                 'download_tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1 and (current_version.t_status == 6 or from_model.app.t_chargemode not in (0, 4) or not (current_version.download_url or \
                         parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0,
                 'backup_tid': from_model.app.t_id if from_model.app.t_id else 0,
                 'name': from_model.app.name,
                 'order': from_model.order,
                 'short_desc': from_model.short_desc,
                 'description': reviewed_version.description,
                 'version': current_version.version,
                 'version_code': current_version.version_code,
                 'package_name': from_model.app.package_name,
                 'price': float(current_version.price),
                 'rate': float(from_model.app.rate),
                 'icon_url': current_version.icon_url or parse_url(current_version.icon_path.url if current_version.icon_path else ''),
                 'category_id': from_model.app.category.id,
                 'sub_category_id': from_model.app.sub_category.id,
                 'cate_name': from_model.app.category.name,
                 'sub_cate_name': from_model.app.sub_category.name,
                 'pub_date': datetime2timestamp(current_version.pub_date, convert_to_utc=True),
                 'download_count': from_model.app.downloads_count,
                 'size': friendly_size(current_version.size),
                 'min_sdk_version': current_version.min_sdk_version,
             }
         app_infos.update(_convert_app_labels(from_model.app.label))
         result_dict.append(app_infos)
     return result_dict
コード例 #6
0
ファイル: adapters.py プロジェクト: liuliainio/liuli
 def convert_to(self, from_model):
     result_dict = []
     if from_model.review_status:
         result_dict.append({
                 'id': from_model.id,
                 'package_name': from_model.package_name,
                 'version_name': from_model.version_name,
                 'source': from_model.source,
                 'version_code': from_model.version_code,
                 'os': from_model.os,
                 'os_version': from_model.os_version,
                 'resolution': from_model.resolution,
                 'cpu': from_model.cpu,
                 'model': from_model.model,
                 'rom': from_model.rom,
                 'update_time': datetime2timestamp(from_model.created_time, convert_to_utc=True),
                 'download_url': from_model.download_url or parse_url(from_model.download_path.url if from_model.download_path else ''),
                 'package_hash': from_model.package_hash or "",
                 'button': from_model.get_buttons(),
                 'title': from_model.title,
                 'content_title': from_model.content_title,
                 'change_log': from_model.change_log,
                 'is_auto': from_model.is_auto,
                 'is_force': from_model.is_force,
                 'is_patch': from_model.is_patch,
                 'package_size': from_model.package_size,
                 'channel_promote': from_model.channel_promote,
                 'device': from_model.device,
             })
     return result_dict
コード例 #7
0
ファイル: adapters.py プロジェクト: liuliainio/liuli
 def convert_to(self, from_model):
     result_dict = []
     current_version = from_model.app.current_version
     reviewed_version = _get_reviewed_version(from_model.app)
     if current_version and from_model.app.review_status:
         app_infos = {
                 'pk': from_model.id,
                 'id': from_model.app.id,
                 'tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1) else 0,
                 'download_tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1 and (current_version.t_status == 6 or from_model.app.t_chargemode not in (0, 4) or not (current_version.download_url or \
                         parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0,
                 'backup_tid': from_model.app.t_id if from_model.app.t_id else 0,
                 'name': from_model.app.name,
                 'order': from_model.order,
                 'short_desc': from_model.short_desc,
                 'description': reviewed_version.description,
                 'version': current_version.version,
                 'version_code': current_version.version_code,
                 'package_name': from_model.app.package_name,
                 'price': float(current_version.price),
                 'rate': float(from_model.app.rate),
                 'icon_url': current_version.icon_url or parse_url(current_version.icon_path.url if current_version.icon_path else ''),
                 'category_id': from_model.app.category.id,
                 'sub_category_id': from_model.app.sub_category.id,
                 'cate_name': from_model.app.category.name,
                 'sub_cate_name': from_model.app.sub_category.name,
                 'pub_date': datetime2timestamp(current_version.pub_date, convert_to_utc=True),
                 'download_count': from_model.app.downloads_count,
                 'size': friendly_size(current_version.size),
                 'min_sdk_version': current_version.min_sdk_version,
             }
         app_infos.update(_convert_app_labels(from_model.app.label))
         result_dict.append(app_infos)
     return result_dict
コード例 #8
0
ファイル: adapters.py プロジェクト: zack-steven-jobs/liuli
 def convert_to(self, from_model):
     result_dict = []
     if from_model.review_status:
         result_dict.append({
             'id':
             from_model.id,
             'name':
             from_model.name,
             'sub_title':
             from_model.sub_title,
             'click_count':
             from_model.clicks_count,
             'order':
             from_model.order,
             'description':
             from_model.description,
             'pub_date':
             datetime2timestamp(from_model.pub_date, convert_to_utc=True),
             'icon_url':
             from_model.icon_url or parse_url(
                 from_model.icon_path.url if from_model.icon_path else ''),
             'large_icon_url':
             from_model.large_icon_url
             or parse_url(from_model.large_icon_path.url if from_model.
                          large_icon_path else ''),
             'subject_tml':
             from_model.subject_tml,
         })
     return result_dict
コード例 #9
0
ファイル: adapters.py プロジェクト: liuliainio/liuli
 def convert_to(self, from_model):
     subject_item = {
             'id': from_model.id,
             'subject_id': from_model.subject.id,
             'title': from_model.title,
             'description': from_model.description,
             'icon_url': from_model.icon_url or parse_url(from_model.icon_path.url if from_model.icon_path else ''),
             'order': from_model.order,
             'subject_info': {
                     'name': from_model.subject.name,
                     'sub_title': from_model.subject.sub_title,
                     'click_count': from_model.subject.clicks_count,
                     'description': from_model.subject.description,
                     'pub_date': datetime2timestamp(from_model.subject.pub_date, convert_to_utc=True),
                 }
         }
     apps = []
     for subject_app in from_model.apps.all().order_by('order'):
         current_version = subject_app.app.current_version
         reviewed_version = _get_reviewed_version(subject_app.app)
         if current_version:
             app_infos = {
                     'pk': subject_app.id,
                     'order': subject_app.order,
                     'id': subject_app.app.id,
                     'tid': subject_app.app.t_id if (subject_app.app.t_id and subject_app.app.t_status == 1) else 0,
                     'download_tid': subject_app.app.t_id if (subject_app.app.t_id and subject_app.app.t_status == 1 and (current_version.t_status == 6 or subject_app.app.t_chargemode not in (0, 4) or not (current_version.download_url or \
                             parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0,
                     'backup_tid': subject_app.app.t_id if subject_app.app.t_id else 0,
                     'name': subject_app.app.name,
                     'description': reviewed_version.description,
                     'version': current_version.version,
                     'version_code': current_version.version_code,
                     'package_name': subject_app.app.package_name,
                     'price': float(subject_app.app.price),
                     'rate': float(subject_app.app.rate),
                     'icon_url': current_version.icon_url or parse_url(current_version.icon_path.url if current_version.icon_path else ''),
                     'pub_date': datetime2timestamp(current_version.pub_date, convert_to_utc=True),
                     'download_count': subject_app.app.downloads_count,
                     'size': friendly_size(current_version.size),
                     'min_sdk_version': current_version.min_sdk_version,
                 }
             app_infos.update(_convert_app_labels(subject_app.app.label))
             apps.append(app_infos)
     subject_item['apps'] = apps
     return [subject_item]
コード例 #10
0
ファイル: adapters.py プロジェクト: liuliainio/liuli
 def convert_to(self, from_model):
     result_dict = []
     group_content = get_region_group(from_model)
     if from_model.review_status:
         result_dict.append({
                 'id': from_model.id,
                 'name': from_model.name,
                 'search_keyword': from_model.search_keyword if from_model.search_keyword else '',
                 'path': from_model.url or parse_url(from_model.path.url if from_model.path else ''),
                 'start_date': datetime2timestamp(from_model.start_date, convert_to_utc=True),
                 'end_date': datetime2timestamp(from_model.end_date, convert_to_utc=True),
                 'is_default': from_model.is_default,
                 'type':from_model.type,
                 'attr':from_model.attr,
                 'region': group_content,
                 'home_banner': from_model.home_banner.strip() if from_model.home_banner else '',
             })
     return result_dict
コード例 #11
0
ファイル: adapters.py プロジェクト: zack-steven-jobs/liuli
 def convert_to(self, from_model):
     result_dict = []
     if from_model.review_status:
         result_dict.append({
             'id':
             from_model.id,
             'package_name':
             from_model.package_name,
             'version_name':
             from_model.version_name,
             'source':
             from_model.source,
             'version_code':
             from_model.version_code,
             'os':
             from_model.os,
             'os_version':
             from_model.os_version,
             'resolution':
             from_model.resolution,
             'cpu':
             from_model.cpu,
             'model':
             from_model.model,
             'rom':
             from_model.rom,
             'update_time':
             datetime2timestamp(from_model.created_time,
                                convert_to_utc=True),
             'download_url':
             from_model.download_url
             or parse_url(from_model.download_path.url if from_model.
                          download_path else ''),
             'package_hash':
             from_model.package_hash or "",
             'button':
             from_model.get_buttons(),
             'title':
             from_model.title,
             'content_title':
             from_model.content_title,
             'change_log':
             from_model.change_log,
             'is_auto':
             from_model.is_auto,
             'is_force':
             from_model.is_force,
             'is_patch':
             from_model.is_patch,
             'package_size':
             from_model.package_size,
             'channel_promote':
             from_model.channel_promote,
             'device':
             from_model.device,
         })
     return result_dict
コード例 #12
0
ファイル: adapters.py プロジェクト: liuliainio/liuli
    def convert_to(self, from_model):
        result_dict = []
        current_version = from_model.current_version
        reviewed_version = _get_reviewed_version(from_model)

        blocked_devices = from_model.blocked_devices if from_model.blocked_devices else ''
        unique_devices = set(dev.strip() for dev in blocked_devices.strip().split(',') if dev)

        external_download_url = current_version.external_download_url if current_version.external_download_url else ''
        external_download_url_set =  set(link for link in external_download_url.strip().split(' ') if link)

        if current_version and from_model.review_status:
            result = {
                    'id': from_model.id,
                    'tid': from_model.t_id if (from_model.t_id and from_model.t_status == 1) else 0,
                    'download_tid': from_model.t_id if (from_model.t_id and from_model.t_status == 1 and (from_model.t_chargemode not in (0, 4) or not (current_version.download_url or \
                            parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0,
                    'backup_tid': from_model.t_id if from_model.t_id else 0,
                    'charge_mode': from_model.t_chargemode,
                    'name': from_model.name,
                    'developer': _get_app_developer(current_version),
                    'description': reviewed_version.description,
                    'update_note': current_version.update_note or "",
                    'price': float(current_version.price),
                    'rate': float(from_model.rate),
                    'package_name': from_model.package_name,
                    'package_sig': from_model.package_sig,
                    'package_hash': current_version.package_hash,
                    'download_count': from_model.downloads_count,
                    'preview_icon_urls': reviewed_version.icon_urls(),
                    'icon_url': current_version.icon_url or parse_url(current_version.icon_path.url if current_version.icon_path else ''),
                    'download_url': current_version.download_url or \
                            parse_url(current_version.download_path.url if current_version.download_path else ''),
                    'external_download_urls':list(external_download_url_set),
                    'version': current_version.version,
                    'version_code': current_version.version_code,
                    'size': friendly_size(current_version.size),
                    'category_id': from_model.category.id,
                    'sub_category_id': from_model.sub_category.id,
                    'cate_name': from_model.category.name,
                    'sub_cate_name': from_model.sub_category.name,
                    'update_date': datetime2timestamp(current_version.modified_time, convert_to_utc=True),
                    'rate_count': from_model.reviews_count,
                    'order': from_model.order,
                    'min_sdk_version': current_version.min_sdk_version,
                    'promote': -1,
                    'blocked_devices': list(unique_devices),
                }
            result.update(_convert_app_labels(from_model.label))

            #tianyi blacklist app control
            #promote_result = get_promote_app(from_model)
            #result.update(promote_result)
            if not result['download_url']:
                result['download_url'] = _get_prev_version_download_url(from_model, current_version.id)
            result_dict.append(result)
        return result_dict
コード例 #13
0
ファイル: adapters.py プロジェクト: liuliainio/liuli
 def convert_to(self, from_model):
     result_dict = []
     group_content = get_region_group(from_model)
     if from_model.review_status:
         result_dict.append({
                 'id': from_model.id,
                 'title': from_model.title,
                 'start_date': datetime2timestamp(from_model.start_date, convert_to_utc=True),
                 'end_date': datetime2timestamp(from_model.end_date, convert_to_utc=True),
                 'description': from_model.description,
                 'icon_url': from_model.icon_url or parse_url(from_model.icon_path.url if from_model.icon_path else ''),
                 'large_icon_url': from_model.large_icon_url or parse_url(from_model.large_icon_path.url if from_model.large_icon_path else ''),
                 'status': from_model.status,
                 'type': from_model.type,
                 'attr': from_model.attr,
                 'tag': from_model.tag,
                 'order': from_model.order,
                 'region': group_content,
             })
     return result_dict
コード例 #14
0
ファイル: adapters.py プロジェクト: liuliainio/liuli
 def convert_to(self, from_model):
     result_dict = []
     group_content = get_region_group(from_model)
     model = {
             'pk': from_model.id,
             'app_list_id': from_model.app_list.id,
             'order': from_model.order,
             'title': from_model.title,
             'description': from_model.description,
             'icon_url': from_model.icon_url or parse_url(from_model.icon_path.url if from_model.icon_path else ''),
             'large_icon_url': from_model.icon_url or parse_url(from_model.icon_path.url if from_model.icon_path else ''),
             'image_url': from_model.icon_url or parse_url(from_model.icon_path.url if from_model.icon_path else ''),
             'attr': from_model.attr,
             'type': from_model.type,
             'extra_infos': {} if not from_model.extra_infos else simplejson.loads(from_model.extra_infos),
             'region': group_content,
         }
     if from_model.app and from_model.app.current_version and from_model.app.review_status:
         current_version = from_model.app.current_version
         reviewed_version = _get_reviewed_version(from_model.app)
         app_infos = {
                 'id': from_model.app.id,
                 'tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1) else 0,
                 'download_tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1 and (current_version.t_status == 6 or from_model.app.t_chargemode not in (0, 4) or not (current_version.download_url or \
                         parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0,
                 'backup_tid': from_model.app.t_id if from_model.app.t_id else 0,
                 'name': from_model.app.name,
                 'developer': _get_app_developer(current_version),
                 'description': reviewed_version.description,
                 'preview_icon_urls': reviewed_version.icon_urls(),
                 'package_name': from_model.app.package_name,
                 'package_sig': from_model.app.package_sig,
                 'version': current_version.version,
                 'version_code': str(current_version.version_code),
                 'tag': from_model.app.tag,
                 'price': float(current_version.price),
                 'rate': float(from_model.app.rate),
                 'icon_url': current_version.icon_url or \
                         parse_url(current_version.icon_path.url if current_version.icon_path else ''),
                 'category_id': from_model.app.category.id if from_model.app.category else 0,
                 'cate_name': from_model.app.category.name if from_model.app.category else '',
                 'sub_category_id': from_model.app.sub_category.id,
                 'sub_cate_name': from_model.app.sub_category.name,
                 'download_count': from_model.app.downloads_count,
                 'size': friendly_size(current_version.size),
                 'update_time': datetime2timestamp(current_version.modified_time, convert_to_utc=True),
                 'min_sdk_version': current_version.min_sdk_version,
             }
         app_infos.update(_convert_app_labels(from_model.app.label))
         model.update({'app': app_infos})
     result_dict.append(model)
     return result_dict
コード例 #15
0
ファイル: adapters.py プロジェクト: liuliainio/liuli
 def convert_to(self, from_model):
     result_dict = []
     if from_model.app_version:
         result_dict.append({
                 'id': from_model.id,
                 'user_id': from_model.user_id,
                 'user_name': from_model.user_name,
                 'app_id': from_model.app_version.app.id,
                 'app_version': from_model.app_version.version,
                 'rate': float(from_model.rate),
                 'comment': from_model.comment,
                 'created_time': datetime2timestamp(from_model.created_time, convert_to_utc=True),
             })
     return result_dict
コード例 #16
0
ファイル: adapters.py プロジェクト: zack-steven-jobs/liuli
 def convert_to(self, from_model):
     message_infos = {
             'id': from_model.id,
             'message_id': from_model.id + 10000,
             'action': _ACTIONS[from_model.action] if from_model.action in _ACTIONS else 'Notification',
             'value': {
                     'display_area': from_model.display_area,
                     'click_value': _get_click_value(from_model) if from_model.action in _CLICK_ACTION_MAPPING \
                             else _get_message_action_url(from_model),
                     'click_action': 'OpenURL' if from_model.action not in _CLICK_ACTION_MAPPING \
                             else _CLICK_ACTION_MAPPING[from_model.action],
                     'description': from_model.content,
                     'clearable': True,
                     'title': from_model.title,
                     'icon_url': '' if not from_model.icon_url and not from_model.icon_path else \
                             (from_model.icon_url or parse_url(from_model.icon_path.url)),
                 },
             'status': from_model.status,
             'created_time': datetime2timestamp(from_model.created_time, convert_to_utc=True),
             'last_modified': datetime2timestamp(from_model.modified_time, convert_to_utc=True),
             'not_valid_before': datetime2timestamp(from_model.invalid_before, convert_to_utc=True),
             'not_valid_after': datetime2timestamp(from_model.invalid_after, convert_to_utc=True),
             'client_id': from_model.client_id,
             'category': from_model.category or 'N/A',
             'short_message': from_model.short_message or 'N/A',
         }
     if from_model.action == PUSH_MESSAGE_ACTIONS.LAUNCHB:
         message_infos['value'].update(
             message_infos['value']['click_value'])
         del message_infos['value']['click_value']
     if from_model.extra_infos:
         message_infos['value'].update(
             simplejson.loads(from_model.extra_infos))
     if from_model.targets:
         message_infos['targets'] = simplejson.loads(from_model.targets)
     return [message_infos]
コード例 #17
0
ファイル: adapters.py プロジェクト: zack-steven-jobs/liuli
 def convert_to(self, from_model):
     result_dict = []
     group_content = get_region_group(from_model)
     if from_model.review_status:
         result_dict.append({
             'id':
             from_model.id,
             'title':
             from_model.title,
             'start_date':
             datetime2timestamp(from_model.start_date, convert_to_utc=True),
             'end_date':
             datetime2timestamp(from_model.end_date, convert_to_utc=True),
             'description':
             from_model.description,
             'icon_url':
             from_model.icon_url or parse_url(
                 from_model.icon_path.url if from_model.icon_path else ''),
             'large_icon_url':
             from_model.large_icon_url
             or parse_url(from_model.large_icon_path.url if from_model.
                          large_icon_path else ''),
             'status':
             from_model.status,
             'type':
             from_model.type,
             'attr':
             from_model.attr,
             'tag':
             from_model.tag,
             'order':
             from_model.order,
             'region':
             group_content,
         })
     return result_dict
コード例 #18
0
ファイル: adapters.py プロジェクト: liuliainio/liuli
 def convert_to(self, from_model):
     result_dict = []
     if from_model.review_status:
         result_dict.append({
                 'id': from_model.id,
                 'name': from_model.name,
                 'sub_title': from_model.sub_title,
                 'click_count': from_model.clicks_count,
                 'order': from_model.order,
                 'description': from_model.description,
                 'pub_date': datetime2timestamp(from_model.pub_date, convert_to_utc=True),
                 'icon_url': from_model.icon_url or parse_url(from_model.icon_path.url if from_model.icon_path else ''),
                 'large_icon_url': from_model.large_icon_url or parse_url(from_model.large_icon_path.url if from_model.large_icon_path else ''),
                 'subject_tml': from_model.subject_tml,
             })
     return result_dict
コード例 #19
0
ファイル: adapters.py プロジェクト: liuliainio/liuli
 def convert_to(self, from_model):
     result_dict = []
     group_content = get_region_group(from_model)
     if from_model.review_status:
         result_dict.append({
             'id': from_model.id,
             'type': from_model.type,
             'attr': from_model.attr,
             'area': from_model.area,
             'order': from_model.order,
             'pub_date': datetime2timestamp(from_model.pub_date, convert_to_utc=True),
             'icon_url': from_model.icon_url or parse_url(from_model.icon_path.url if from_model.icon_path else ''),
             'category_id': from_model.category.id if from_model.category else 0,
             'recommend_type': from_model.recommend_type,
             'region': group_content,
             'cooperate_list_id': from_model.cooperate_list_id.strip() if from_model.cooperate_list_id else '',
             'cooperate_list_name': from_model.cooperate_list_name.strip() if from_model.cooperate_list_name else ''
         })
     return result_dict
コード例 #20
0
ファイル: adapters.py プロジェクト: zack-steven-jobs/liuli
 def convert_to(self, from_model):
     result_dict = []
     if from_model.app_version:
         result_dict.append({
             'id':
             from_model.id,
             'user_id':
             from_model.user_id,
             'user_name':
             from_model.user_name,
             'app_id':
             from_model.app_version.app.id,
             'app_version':
             from_model.app_version.version,
             'rate':
             float(from_model.rate),
             'comment':
             from_model.comment,
             'created_time':
             datetime2timestamp(from_model.created_time,
                                convert_to_utc=True),
         })
     return result_dict
コード例 #21
0
ファイル: adapters.py プロジェクト: zack-steven-jobs/liuli
    def convert_to(self, from_model):
        result_dict = []
        current_version = from_model.current_version
        reviewed_version = _get_reviewed_version(from_model)

        blocked_devices = from_model.blocked_devices if from_model.blocked_devices else ''
        unique_devices = set(dev.strip()
                             for dev in blocked_devices.strip().split(',')
                             if dev)

        external_download_url = current_version.external_download_url if current_version.external_download_url else ''
        external_download_url_set = set(
            link for link in external_download_url.strip().split(' ') if link)

        if current_version and from_model.review_status:
            result = {
                    'id': from_model.id,
                    'tid': from_model.t_id if (from_model.t_id and from_model.t_status == 1) else 0,
                    'download_tid': from_model.t_id if (from_model.t_id and from_model.t_status == 1 and (from_model.t_chargemode not in (0, 4) or not (current_version.download_url or \
                            parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0,
                    'backup_tid': from_model.t_id if from_model.t_id else 0,
                    'charge_mode': from_model.t_chargemode,
                    'name': from_model.name,
                    'developer': _get_app_developer(current_version),
                    'description': reviewed_version.description,
                    'update_note': current_version.update_note or "",
                    'price': float(current_version.price),
                    'rate': float(from_model.rate),
                    'package_name': from_model.package_name,
                    'package_sig': from_model.package_sig,
                    'package_hash': current_version.package_hash,
                    'download_count': from_model.downloads_count,
                    'preview_icon_urls': reviewed_version.icon_urls(),
                    'icon_url': current_version.icon_url or parse_url(current_version.icon_path.url if current_version.icon_path else ''),
                    'download_url': current_version.download_url or \
                            parse_url(current_version.download_path.url if current_version.download_path else ''),
                    'external_download_urls':list(external_download_url_set),
                    'version': current_version.version,
                    'version_code': current_version.version_code,
                    'size': friendly_size(current_version.size),
                    'category_id': from_model.category.id,
                    'sub_category_id': from_model.sub_category.id,
                    'cate_name': from_model.category.name,
                    'sub_cate_name': from_model.sub_category.name,
                    'update_date': datetime2timestamp(current_version.modified_time, convert_to_utc=True),
                    'rate_count': from_model.reviews_count,
                    'order': from_model.order,
                    'min_sdk_version': current_version.min_sdk_version,
                    'promote': -1,
                    'blocked_devices': list(unique_devices),
                }
            result.update(_convert_app_labels(from_model.label))

            #tianyi blacklist app control
            #promote_result = get_promote_app(from_model)
            #result.update(promote_result)
            if not result['download_url']:
                result['download_url'] = _get_prev_version_download_url(
                    from_model, current_version.id)
            result_dict.append(result)
        return result_dict
コード例 #22
0
ファイル: adapters.py プロジェクト: zack-steven-jobs/liuli
 def convert_to(self, from_model):
     result_dict = []
     group_content = get_region_group(from_model)
     model = {
         'pk':
         from_model.id,
         'app_list_id':
         from_model.app_list.id,
         'order':
         from_model.order,
         'title':
         from_model.title,
         'description':
         from_model.description,
         'icon_url':
         from_model.icon_url or parse_url(
             from_model.icon_path.url if from_model.icon_path else ''),
         'large_icon_url':
         from_model.icon_url or parse_url(
             from_model.icon_path.url if from_model.icon_path else ''),
         'image_url':
         from_model.icon_url or parse_url(
             from_model.icon_path.url if from_model.icon_path else ''),
         'attr':
         from_model.attr,
         'type':
         from_model.type,
         'extra_infos': {} if not from_model.extra_infos else
         simplejson.loads(from_model.extra_infos),
         'region':
         group_content,
     }
     if from_model.app and from_model.app.current_version and from_model.app.review_status:
         current_version = from_model.app.current_version
         reviewed_version = _get_reviewed_version(from_model.app)
         app_infos = {
                 'id': from_model.app.id,
                 'tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1) else 0,
                 'download_tid': from_model.app.t_id if (from_model.app.t_id and from_model.app.t_status == 1 and (current_version.t_status == 6 or from_model.app.t_chargemode not in (0, 4) or not (current_version.download_url or \
                         parse_url(current_version.download_path.url if current_version.download_path else '')))) else 0,
                 'backup_tid': from_model.app.t_id if from_model.app.t_id else 0,
                 'name': from_model.app.name,
                 'developer': _get_app_developer(current_version),
                 'description': reviewed_version.description,
                 'preview_icon_urls': reviewed_version.icon_urls(),
                 'package_name': from_model.app.package_name,
                 'package_sig': from_model.app.package_sig,
                 'version': current_version.version,
                 'version_code': str(current_version.version_code),
                 'tag': from_model.app.tag,
                 'price': float(current_version.price),
                 'rate': float(from_model.app.rate),
                 'icon_url': current_version.icon_url or \
                         parse_url(current_version.icon_path.url if current_version.icon_path else ''),
                 'category_id': from_model.app.category.id if from_model.app.category else 0,
                 'cate_name': from_model.app.category.name if from_model.app.category else '',
                 'sub_category_id': from_model.app.sub_category.id,
                 'sub_cate_name': from_model.app.sub_category.name,
                 'download_count': from_model.app.downloads_count,
                 'size': friendly_size(current_version.size),
                 'update_time': datetime2timestamp(current_version.modified_time, convert_to_utc=True),
                 'min_sdk_version': current_version.min_sdk_version,
             }
         app_infos.update(_convert_app_labels(from_model.app.label))
         model.update({'app': app_infos})
     result_dict.append(model)
     return result_dict