拍爱

models.py 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. # -*- coding: utf-8 -*-
  2. import os
  3. from django.conf import settings
  4. from django.db import models
  5. from django.utils.translation import ugettext_lazy as _
  6. from TimeConvert import TimeConvert as tc
  7. from pai2.basemodels import CreateUpdateMixin, PlatformMixin, VersionMixin
  8. def upload_path(instance, old_filename):
  9. return 'file/{ym}/{stamp}{ext}'.format(
  10. ym=tc.local_string(format='%Y%m'),
  11. stamp=tc.local_timestamp(ms=True),
  12. ext=os.path.splitext(old_filename)[1].lower(),
  13. )
  14. class LatestAppInfo(CreateUpdateMixin):
  15. PAIAI_USER = 0
  16. PAIAI_LENSMAN = 1
  17. PAIAI_TOURGUIDE = 2
  18. SRC = (
  19. (PAIAI_USER, u'拍爱用户端'),
  20. (PAIAI_LENSMAN, u'拍爱摄影师端'),
  21. (PAIAI_TOURGUIDE, u'拍爱导游端'),
  22. )
  23. latest_adr_version_code = models.IntegerField(_(u'latest_adr_version_code'), default=0, help_text=u'最新安卓版本号')
  24. latest_adr_version_name = models.CharField(_(u'latest_adr_version_name'), max_length=255, blank=True, null=True, help_text=u'最新安卓版本名')
  25. latest_adr_app = models.FileField(_(u'latest_adr_app'), upload_to=upload_path, blank=True, null=True, help_text=u'最新版安卓 APP')
  26. latest_adr_url = models.URLField(_(u'latest_adr_url'), max_length=255, blank=True, null=True, help_text=u'最新版 APP 链接')
  27. latest_ios_version_code = models.IntegerField(_(u'latest_ios_version_code'), default=0, help_text=u'最新 iOS 版本号')
  28. latest_ios_version_name = models.CharField(_(u'latest_ios_version_name'), max_length=255, blank=True, null=True, help_text=u'最新 iOS 版本名')
  29. latest_ios_url = models.URLField(_(u'latest_ios_url'), max_length=255, blank=True, null=True, help_text=u'最新版 iOS 链接')
  30. src = models.IntegerField(_(u'src'), choices=SRC, default=PAIAI_USER, help_text=u'最新版来源', db_index=True)
  31. class Meta:
  32. verbose_name = _('latestappinfo')
  33. verbose_name_plural = _('latestappinfo')
  34. def __unicode__(self):
  35. return u'{0.pk}'.format(self)
  36. @property
  37. def final_latest_adr_url(self):
  38. return self.latest_adr_url or u'{}{}'.format(settings.DOMAIN, self.latest_adr_app and self.latest_adr_app.url)
  39. @property
  40. def data(self):
  41. return {
  42. 'latest_adr_version_code': self.latest_adr_version_code,
  43. 'latest_adr_version_name': self.latest_adr_version_name,
  44. 'latest_adr_url': self.final_latest_adr_url,
  45. 'latest_ios_version_code': self.latest_ios_version_code,
  46. 'latest_ios_version_name': self.latest_ios_version_name,
  47. 'latest_ios_url': self.latest_ios_url,
  48. }
  49. class APPSettingsInfo(CreateUpdateMixin, PlatformMixin):
  50. channel = models.CharField(_(u'channel'), max_length=255, blank=True, null=True, help_text=u'渠道')
  51. version = models.CharField(_(u'version'), max_length=255, blank=True, null=True, help_text=u'版本')
  52. online = models.BooleanField(_(u'online'), default=True, help_text=u'是否上线')
  53. class Meta:
  54. verbose_name = _('appsettingsinfo')
  55. verbose_name_plural = _('appsettingsinfo')
  56. def __unicode__(self):
  57. return u'{0.pk}'.format(self)
  58. @property
  59. def data(self):
  60. return {
  61. 'online': self.online,
  62. }
  63. class SplashInfo(CreateUpdateMixin):
  64. PAIAI_USER = 0
  65. PAIAI_LENSMAN = 1
  66. PAIAI_TOURGUIDE = 2
  67. SRC = (
  68. (PAIAI_USER, u'拍爱用户端'),
  69. (PAIAI_LENSMAN, u'拍爱摄影师端'),
  70. (PAIAI_TOURGUIDE, u'拍爱导游端'),
  71. )
  72. splash_image = models.ImageField(_(u'splash_image'), upload_to=upload_path, blank=True, null=True, help_text=u'启动页面图片')
  73. spalash_image_airtime = models.DateTimeField(_(u'spalash_image_airtime'), blank=True, null=True, help_text=u'启动页面图片开始日期')
  74. spalash_image_deadline = models.DateTimeField(_(u'spalash_image_deadline'), blank=True, null=True, help_text=u'启动页面图片截止日期')
  75. src = models.IntegerField(_(u'src'), choices=SRC, default=PAIAI_USER, help_text=u'启动页面来源', db_index=True)
  76. class Meta:
  77. verbose_name = _('splashinfo')
  78. verbose_name_plural = _('splashinfo')
  79. def __unicode__(self):
  80. return u'{0.pk}'.format(self)
  81. @property
  82. def splash_image_url(self):
  83. return self.splash_image and (settings.DOMAIN + self.splash_image.url)
  84. @property
  85. def data(self):
  86. return {
  87. 'splash_image_url': self.splash_image_url,
  88. 'spalash_image_airtime': self.spalash_image_airtime,
  89. 'spalash_image_deadline': self.spalash_image_deadline,
  90. }
  91. class FeedbackInfo(CreateUpdateMixin):
  92. PAIAI_USER = 0
  93. PAIAI_LENSMAN = 1
  94. PAIAI_TOURGUIDE = 2
  95. SRC = (
  96. (PAIAI_USER, u'拍爱用户端'),
  97. (PAIAI_LENSMAN, u'拍爱摄影师端'),
  98. (PAIAI_TOURGUIDE, u'拍爱导游端'),
  99. )
  100. user_id = models.CharField(_(u'user_id'), max_length=255, blank=True, null=True, help_text=u'用户唯一标识')
  101. feedback = models.TextField(_(u'feedback'), blank=True, null=True, help_text=u'用户反馈')
  102. src = models.IntegerField(_(u'src'), choices=SRC, default=PAIAI_USER, help_text=u'用户反馈来源', db_index=True)
  103. class Meta:
  104. verbose_name = _('feedbackinfo')
  105. verbose_name_plural = _('feedbackinfo')
  106. def __unicode__(self):
  107. return u'{0.pk}'.format(self)
  108. class GuestEntranceControlInfo(CreateUpdateMixin, PlatformMixin, VersionMixin):
  109. class Meta:
  110. verbose_name = _('guestentrancecontrolinfo')
  111. verbose_name_plural = _('guestentrancecontrolinfo')
  112. def __unicode__(self):
  113. return u'{0.pk}'.format(self)
  114. @property
  115. def data(self):
  116. return {
  117. 'platform': self.platform,
  118. 'min_adr': self.min_adr,
  119. 'min_ios': self.min_ios,
  120. 'max_adr': self.max_adr,
  121. 'max_ios': self.max_ios,
  122. }