Advertisement
Guest User

Dudas con el ColorFul or ColorField

a guest
Sep 19th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 11.32 KB | None | 0 0
  1. #---------------------settings/base.py-----------------------------------
  2. # ---DESPUES DE HACER EL PIP INSTALL TANTO COLORFUL Y COLORFIELD---------
  3. #----- LO AGREGUE EN INSTALLED_APPS, DESPUES DE ESTO LE HICE-------------
  4. #------ ./manage.py collectstatic ---------------------------------------
  5. #------ y con esto pense que ya podia usarlo en el forms/__init__py------
  6. """
  7. Django settings for pac_gateway project.
  8.  
  9. Generated by 'django-admin startproject' using Django 1.9.5.
  10.  
  11. For more information on this file, see
  12. https://docs.djangoproject.com/en/1.9/topics/settings/
  13.  
  14. For the full list of settings and their values, see
  15. https://docs.djangoproject.com/en/1.9/ref/settings/
  16. """
  17.  
  18. import os
  19.  
  20. DEBUG = False
  21.  
  22. if os.environ.get('DJANGO_DEBUG', False):
  23.     DEBUG = True
  24.  
  25. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  26. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  27.  
  28. # Quick-start development settings - unsuitable for production
  29. # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
  30.  
  31. # SECURITY WARNING: keep the secret key used in production secret!
  32. SECRET_KEY = 'nbqoc-^@f#1(g#cux^w*$%14opecsr8np@m^h2vykctm+76!pw'
  33.  
  34. ALLOWED_HOSTS = []
  35.  
  36. # Application definition
  37.  
  38. INSTALLED_APPS = [
  39.     'django.contrib.admin',
  40.     'django.contrib.auth',
  41.     'django.contrib.contenttypes',
  42.     'django.contrib.sessions',
  43.     'django.contrib.messages',
  44.     'django.contrib.staticfiles',
  45.     'django.contrib.postgres',
  46.     'rest_framework.authtoken',
  47.     'rest_framework',
  48.     'corsheaders',
  49.     'rest_framework_swagger',
  50.     'anymail',
  51.     'pac_gateway.cfd',
  52.     'daterange_filter',
  53.     'colorfield',
  54.     'colorful',
  55. ]
  56.  
  57. # INSTALLED_APPS.append('colorful'),
  58.  
  59. MIDDLEWARE_CLASSES = [
  60.     'django.middleware.security.SecurityMiddleware',
  61.     'django.contrib.sessions.middleware.SessionMiddleware',
  62.     'corsheaders.middleware.CorsMiddleware',
  63.     'django.middleware.common.CommonMiddleware',
  64.     'django.middleware.csrf.CsrfViewMiddleware',
  65.     'django.contrib.auth.middleware.AuthenticationMiddleware',
  66.     'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
  67.     'django.contrib.messages.middleware.MessageMiddleware',
  68.     'django.middleware.clickjacking.XFrameOptionsMiddleware',
  69. ]
  70.  
  71. CORS_ORIGIN_ALLOW_ALL = True
  72. CORS_ALLOW_CREDENTIALS = True
  73.  
  74. ROOT_URLCONF = 'pac_gateway.urls'
  75.  
  76. TEMPLATES = [
  77.     {
  78.         'BACKEND': 'django.template.backends.django.DjangoTemplates',
  79.         'DIRS': [os.path.join(BASE_DIR, 'templates'), ],
  80.         'APP_DIRS': True,
  81.         'OPTIONS': {
  82.             'context_processors': [
  83.                 'django.template.context_processors.debug',
  84.                 'django.template.context_processors.request',
  85.                 'django.contrib.auth.context_processors.auth',
  86.                 'django.contrib.messages.context_processors.messages',
  87.             ],
  88.             'debug': DEBUG
  89.         },
  90.     },
  91. ]
  92.  
  93. WSGI_APPLICATION = 'pac_gateway.wsgi.application'
  94.  
  95. # Password validation
  96. # https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
  97.  
  98. AUTH_PASSWORD_VALIDATORS = [
  99.     {
  100.         'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
  101.     },
  102.     {
  103.         'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
  104.     },
  105.     {
  106.         'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
  107.     },
  108.     {
  109.         'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
  110.     },
  111. ]
  112.  
  113. # Internationalization
  114. # https://docs.djangoproject.com/en/1.9/topics/i18n/
  115.  
  116. LANGUAGE_CODE = 'es'
  117.  
  118. TIME_ZONE = 'UTC'
  119.  
  120. USE_I18N = True
  121.  
  122. # USE_L10N = True
  123.  
  124. USE_TZ = True
  125.  
  126. LOCALE_PATHS = (
  127.     os.path.join(BASE_DIR, 'locale'),
  128. )
  129.  
  130. # Static files (CSS, JavaScript, Images)
  131. # https://docs.djangoproject.com/en/1.9/howto/static-files/
  132.  
  133. STATIC_URL = '/static/'
  134. STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  135.  
  136. # Rest Framework
  137.  
  138. REST_FRAMEWORK = {
  139.     'DEFAULT_PERMISSION_CLASSES': (
  140.         'rest_framework.permissions.IsAuthenticated',
  141.     ),
  142.     'DEFAULT_FILTER_BACKENDS': (
  143.         'rest_framework.filters.DjangoFilterBackend',
  144.         'rest_framework.filters.SearchFilter'
  145.     ),
  146.     'DEFAULT_AUTHENTICATION_CLASSES': (
  147.         'rest_framework.authentication.SessionAuthentication',
  148.         'rest_framework.authentication.TokenAuthentication'
  149.     ),
  150.     'DEFAULT_PAGINATION_CLASS': (
  151.         'rest_framework.pagination.LimitOffsetPagination'
  152.     )
  153. }
  154.  
  155. LOGIN_REDIRECT_URL = "/api/docs/"
  156.  
  157. # PAC Gateway setup
  158. CFDI_DEFAULT_VERSION = '3.2'
  159. CFDI_IR_SCHEMA_PATH = os.path.join(BASE_DIR, 'share', 'schemas',
  160.                                    'comprobante.json')
  161.  
  162. PAC_GATEWAY_ENCRYPTION_KEY = os.environ.get('PAC_GATEWAY_ENCRYPTION_KEY', '')
  163.  
  164. FINKOK_USERNAME = os.environ.get('FINKOK_USERNAME', '')
  165. FINKOK_PASSWORD = os.environ.get('FINKOK_PASSWORD', '')
  166.  
  167. PAC_GATEWAY_AVAIL_SHEETS_WARNING_PCT = 0.125
  168.  
  169. PAC_GATEWAY_DEFAULT_CERTIFICATION_DAYS = 3
  170.  
  171. PAC_GATEWAY_FROM_EMAIL = "support@f-ambit.mx"
  172.  
  173. # SAT Formats
  174. SAT_DATE_FORMAT = '%Y-%m-%dT%H:%M:%S'
  175.  
  176. # Default prefixes
  177. PAC_GATEWAY_DEFAULT_GLOBAL_INVOICE_PREFIX = 'FG'
  178. PAC_GATEWAY_DEFAULT_GLOBAL_CREDIT_NOTE_PREFIX = 'NCG'
  179. PAC_GATEWAY_DEFAULT_CREDIT_NOTE_PREFIX = 'NC'
  180.  
  181. # Payment form strings
  182. PAC_GATEWAY_PAYMENT_FORM_SINGLE = 'Pago en una sola exhibición'
  183. PAC_GATEWAY_PAYMENT_FORM_MULTIPLE = 'Parcialidad {part} de {total_parts}'
  184.  
  185. # Invoice defaults
  186. PAC_GATEWAY_DEFAULT_SAT_PAYMENT_METHOD = '01'
  187. PAC_GATEWAY_DEFAULT_UNIT = 'Unidad'
  188.  
  189. PAC_GATEWAY_INSTALLED_APPS = {
  190.     'lightspeed-retail': ('pac_gateway.applications.lightspeed'
  191.                           '.retail.LightSpeedRetailHandler')
  192. }
  193.  
  194. DEFAULT_PAF_CONFIG = {
  195.     'palette': {
  196.         'bg': '#F9F9F9',
  197.         'header_bg': '#FDFDFD',
  198.         'container_bg': '#FFFFFF',
  199.         'title_bg': '#E31818',
  200.         'form_footer_bg': '#F5F5F5',
  201.         'footer_bg': '#FDFDFD',
  202.         'primary_button_bg': '#E31818',
  203.         'secondary_button_bg': '#A0A0A0',
  204.         'font_color': '#838383',
  205.         'title_color': '#FFFFFF',
  206.         'link_color': '#337AB7',
  207.         'primary_button_color': '#FFFFFF',
  208.         'secondary_button_color': '#FFFFFF',
  209.         'form_footer_color': '#838383',
  210.         'footer_color': '#838383'
  211.     }
  212. }
  213.  
  214. # Invoice PDF setup
  215.  
  216. INVOICE_PDF_PAGESIZE = 'letter'
  217. INVOICE_PDF_ORIENTATION = 'portrait'
  218. INVOICE_PDF_MARGIN = '1cm'
  219. INVOICE_PDF_PADDING = '0'
  220.  
  221. # Swagger settings
  222. SWAGGER_SETTINGS = {
  223.     'api_version': '0.1',
  224.     'api_path': '/api/v1/',
  225.     'enabled_methods': [
  226.         'get',
  227.         'post',
  228.     ],
  229.     'is_authenticated': True,
  230.     'permission_denied_handler': 'pac_gateway.cfd.views.permission_denied_handler',
  231.     'info': {
  232.         'contact': 'team@uakami.com',
  233.         'description': 'API Pac Gateway to search, claim and stamp invoices. ',
  234.         # 'license': 'Apache 2.0',
  235.         # 'licenseUrl': 'http://www.apache.org/licenses/LICENSE-2.0.html',
  236.         # 'termsOfServiceUrl': 'http://helloreverb.com/terms/',
  237.         'title': 'Ambit - API Pac Gateway',
  238.     }
  239. }
  240.  
  241. # Anymail settings
  242. ANYMAIL = {
  243.     "MAILGUN_API_KEY": os.environ.get('MAILGUN_API_KEY', None)
  244. }
  245.  
  246. EMAIL_BACKEND = "anymail.backends.mailgun.MailgunBackend"
  247. DEFAULT_FROM_EMAIL = "no-reply@f-ambit.mx"
  248.  
  249. #---------------------forms/__init__.py-----------------------------------
  250. #---------------AQUI ES DONDE QUIERO USARLO-------------------------------
  251.  
  252. # from colorful.fields import RGBColorField
  253. # from  colorful.fields import  RGBColorField
  254. # from colorfield.fields import ColorField
  255. from django import forms
  256. from django.contrib.admin.widgets import AdminSplitDateTime
  257. from django.utils.translation import ugettext_lazy as _
  258.  
  259. from pac_gateway.cfd.models import CFD
  260. from pac_gateway.cfd.models import OrganizationCertificate
  261. from .fields import ColorField
  262.  
  263.  
  264. class OrganizationCertificateForm(forms.ModelForm):
  265.     pwd = forms.CharField(
  266.         max_length=64,
  267.         label=_('Certificate Password'),
  268.         help_text=_('Only for setting the password'),
  269.         required=False,
  270.         widget=forms.PasswordInput
  271.     )
  272.  
  273.     def save(self, *args, **kwargs):
  274.         self.instance.pwd = self.cleaned_data['pwd']
  275.         return super(OrganizationCertificateForm, self).save(*args, **kwargs)
  276.  
  277.     class Meta:
  278.         model = OrganizationCertificate
  279.         fields = ('der_certificate', 'der_key',
  280.                   'pwd',)
  281.  
  282.  
  283. class PAFConfigForm(forms.Form):
  284.     # Backgrounds
  285.     bg = ColorField(
  286.         label=_('Main Background'),
  287.         required=False,
  288.     )
  289.     header_bg = ColorField(
  290.         label=_('Header Background'),
  291.         required=False,
  292.     )
  293.     container_bg = ColorField(
  294.         label=_('Container bg'),
  295.         required=False,
  296.     )
  297.     title_bg = ColorField(
  298.         label=_('Title bg'),
  299.         required=False,
  300.     )
  301.     footer_bg = ColorField(
  302.         label=_('Footer bg'),
  303.         required=False,
  304.     )
  305.     form_footer_bg = ColorField(
  306.         label=_('Form footer bg'),
  307.         required=False,
  308.     )
  309.     primary_button_bg = ColorField(
  310.         label=_('Primary btn bg'),
  311.         required=False,
  312.     )
  313.     secondary_button_bg = ColorField(
  314.         label=_('Secondary btn bg'),
  315.         required=False,
  316.     )
  317.  
  318.     # Font colors
  319.     font_color = ColorField(
  320.         label=('Font color'),
  321.         required=False,
  322.     )
  323.     title_color = ColorField(
  324.         label=_('Title color'),
  325.         required=False,
  326.     )
  327.     link_color = ColorField(
  328.         label=_('Link color'),
  329.         required=False,
  330.     )
  331.     primary_button_color = ColorField(
  332.         label=_('Primary btn color'),
  333.         required=False,
  334.     )
  335.     secondary_button_color = ColorField(
  336.         label=_('secondary btn color'),
  337.         required=False,
  338.     )
  339.     form_footer_color = ColorField(required=False)
  340.     footer_color = ColorField(required=False)
  341.  
  342.     # Images
  343.     logo = forms.CharField(
  344.         label=_('Image: Logo (250x125)'),
  345.         required=False
  346.     )
  347.  
  348.     # URLs and contact
  349.     website_url = forms.URLField(
  350.         label=_('Website Url'),
  351.         required=False
  352.     )
  353.     email = forms.EmailField(
  354.         label=_('Email')
  355.     )
  356.     phone_number = forms.CharField(
  357.         label=_('Phone Number')
  358.     )
  359.  
  360.     # Copies
  361.     claiming_period_text = forms.CharField(
  362.         required=False,
  363.         widget=forms.Textarea,
  364.         label=_('Claim')
  365.     )
  366.     support_text = forms.CharField(
  367.         required=False,
  368.         widget=forms.Textarea,
  369.         label=_('Support')
  370.     )
  371.  
  372.  
  373. class AllocateTaxSheetsForm(forms.Form):
  374.     sheets = forms.IntegerField(
  375.         label=_('Number of sheets'),
  376.         help_text=_(
  377.             'Total number of tax sheets to allocate for the organization'
  378.         ),
  379.     )
  380.  
  381.  
  382. class ClosingDateForm(forms.Form):
  383.     CLASS_GLOBAL_CHOICES = (
  384.         (CFD.CLASS_GLOBAL_INVOICE, _('Global Invoice')),
  385.         (CFD.CLASS_GLOBAL_CREDIT_NOTE, _('Global Credit Note'))
  386.     )
  387.  
  388.     invoice_class = forms.ChoiceField(
  389.         choices=CLASS_GLOBAL_CHOICES,
  390.         initial=CFD.CLASS_GLOBAL_INVOICE,
  391.         help_text=_('Class of the global invoice'),
  392.         label=_('Global invoice class')
  393.     )
  394.  
  395.     date = forms.SplitDateTimeField(
  396.         label=_('Closing date and time'),
  397.         help_text=_(
  398.             'Date and time for the closing of the global invoice or credit note'
  399.         ),
  400.         widget=AdminSplitDateTime
  401.     )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement