利标题') welfare_detail = RichTextField(_(u'welfare_detail'), blank=True, null=True, help_text=u'福利详情') welfare_value = models.IntegerField(_(u'welfare_value'), default=0, help_text=u'福利数量') welfare_image = models.ImageField(_(u'welfare_image'), upload_to=upload_path, blank=True, null=True, help_text=u'福利图片') is_upload_qiniu = models.BooleanField(_(u'is_upload_qiniu'), default=False, help_text=u'是否已上传七牛') class Meta: verbose_name = _(u'会员活动投稿福利信息') verbose_name_plural = _(u'会员活动投稿福利信息') def __unicode__(self): return '%d' % self.pk @property def welfare_image_path(self): return upload_file_path(self.welfare_image) @property def welfare_image_url(self): return qiniu_file_url(self.welfare_image.name, bucket='tamron') if self.is_upload_qiniu else upload_file_url(self.welfare_image) @property def data(self): return { 'welfare_id': self.welfare_id, 'brand_id': self.brand_id, 'brand_name': self.brand_name, 'activity_id': self.activity_id, 'welfare_type': self.welfare_type, 'welfare_type_str': dict(MemberActivityContributionWelfareInfo.WELFARE_TYPE).get(self.welfare_type), 'welfare_title': self.welfare_title, 'welfare_detail': self.welfare_detail, 'welfare_value': self.welfare_value, 'welfare_image_url': self.welfare_image_url, 'welfare_image_path': self.welfare_image_path, } class MemberActivityContributionWelfareUnlockingInfo(BaseModelMixin, BrandInfoMixin): WELFARE_INTEGRAL = 1 WELFARE_TYPE = ( (0, u'实物'), (1, u'积分'), (2, u'虚拟'), ) unlocking_id = ShortUUIDField(_(u'unlocking_id'), max_length=32, blank=True, null=True, help_text=u'福利解锁唯一标识', db_index=True, unique=True) admin_id = models.CharField(_(u'admin_id'), max_length=32, blank=True, null=True, help_text=u'管理员唯一标识', db_index=True) user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True) activity_id = models.CharField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True) contribution_id = models.CharField(_(u'contribution_id'), max_length=32, blank=True, null=True, help_text=u'投稿唯一标识', db_index=True) welfare_id = models.CharField(_(u'welfare_id'), max_length=32, blank=True, null=True, help_text=u'福利唯一标识', db_index=True) welfare_type = models.IntegerField(_(u'welfare_type'), choices=WELFARE_TYPE, default=0, help_text=u'福利类型', db_index=True) welfare_value = models.IntegerField(_(u'welfare_value'), default=0, help_text=u'福利数量') name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'姓名') phone = models.CharField(_(u'phone'), max_length=255, blank=True, null=True, help_text=u'电话') address = models.CharField(_(u'address'), max_length=255, blank=True, null=True, help_text=u'地址') tracking_number = models.CharField(_(u'tracking_number'), max_length=255, blank=True, null=True, help_text=u'快递单号') is_handled = models.BooleanField(_(u'is_handled'), default=False, help_text=u'是否已处理') send_template_message_res = JSONField(_(u'send_template_message_res'), blank=True, null=True, help_text=u'send_template_message_res') class Meta: verbose_name = _(u'会员活动投稿福利解锁信息') verbose_name_plural = _(u'会员活动投稿福利解锁信息') unique_together = ( ('brand_id', 'activity_id', 'welfare_id', 'user_id'), ) def __unicode__(self): return '%d' % self.pk @property def data(self): try: welfare = MemberActivityContributionWelfareInfo.objects.get(welfare_id=self.welfare_id) except MemberActivityContributionWelfareInfo.DoesNotExist: welfare = None try: user = MemberActivitySignupInfo.objects.get(user_id=self.user_id, activity_id=self.activity_id) except MemberActivitySignupInfo.DoesNotExist: user = None return { 'unlocking_id': self.unlocking_id, 'brand_id': self.brand_id, 'brand_name': self.brand_name, 'admin_id': self.admin_id, 'user_id': self.user_id, 'activity_id': self.activity_id, 'contribution_id': self.contribution_id, 'welfare_id': self.welfare_id, 'welfare': welfare.data if welfare else {}, 'name': self.name, 'phone': self.phone, 'address': self.address, 'tracking_number': self.tracking_number, 'is_handled': self.is_handled, 'created_at': tc.local_string(utc_dt=self.created_at), 'username': user.name if user else '', 'useravatar': user.final_avatar if user else '', } kodo - Gogs: Go Git Service

Nenhuma Descrição

admin.py 1.9KB

    # -*- coding: utf-8 -*- from django.contrib import admin from django_admin import ChangeOnlyModelAdmin, ReadOnlyModelAdmin from account.models import UserInfo, UserIntegralIncomeExpensesInfo, LensmanInfo from mch.models import ConsumeInfoSubmitLogInfo class UserInfoAdmin(ChangeOnlyModelAdmin, admin.ModelAdmin): list_display = ('user_id', 'nickname', 'phone', 'appid', 'unionid', 'openid', 'openid_miniapp', 'location', 'balance', 'user_status', 'test_user', 'integral', 'freeze_integral', 'shots_num', 'level', 'coupon_expire_at', 'is_maintenance', 'status', 'created_at', 'updated_at') list_filter = ('user_from', 'appid', 'subscribe', 'has_membercard', 'test_user', 'is_maintenance', 'sex', 'user_status', 'status', 'code_version', 'new_subscribe', 'created_at', 'integral') readonly_fields = ('user_id', ) search_fields = ('user_id', 'username', 'unionid', 'openid', 'openid_miniapp', 'name', 'phone', 'location', 'memberusercardcode') def save_model(self, request, obj, form, change): obj.save() if obj.test_user: ConsumeInfoSubmitLogInfo.objects.filter(user_id=obj.user_id).update(test_user=True) class LensmanInfoAdmin(ChangeOnlyModelAdmin, admin.ModelAdmin): list_display = ('lensman_id', 'user_id', 'name', 'phone', 'lensman_status', 'start_date', 'end_date', 'status', 'updated_at', 'created_at') list_filter = ('lensman_status', 'status') search_fields = ('user_id', 'name', 'phone') class UserIntegralIncomeExpensesInfoAdmin(ChangeOnlyModelAdmin, admin.ModelAdmin): list_display = ('user_id', 'brand_id', 'brand_name', 'model_id', 'model_name', 'code', 'integral_from', 'integral', 'final_integral', 'remark', 'updated_at', 'created_at') list_filter = ('integral_from', 'status') search_fields = ('user_id', ) admin.site.register(UserInfo, UserInfoAdmin) admin.site.register(LensmanInfo, LensmanInfoAdmin) admin.site.register(UserIntegralIncomeExpensesInfo, UserIntegralIncomeExpensesInfoAdmin)