From 77e279423eb4ae783e398b76aed47d4ed5e5a64b Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 21 Jan 2021 11:37:54 +0000 Subject: [PATCH] added Company model, switched backend config to postgis --- back_latienda/settings/development.py | 5 +++- back_latienda/urls.py | 5 +++- companies/models.py | 37 ++++++++++++++++++++++++++- media/.gitignore | 2 ++ 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 media/.gitignore diff --git a/back_latienda/settings/development.py b/back_latienda/settings/development.py index 063876a..7b1738e 100644 --- a/back_latienda/settings/development.py +++ b/back_latienda/settings/development.py @@ -11,7 +11,7 @@ ALLOWED_HOSTS = [] # Databases configuration DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': os.getenv('DB_NAME'), 'USER': os.getenv('DB_USER'), 'PASSWORD': os.getenv('DB_PASSWORD'), @@ -19,3 +19,6 @@ DATABASES = { 'PORT': os.getenv('DB_PORT'), }, } + +MEDIA_ROOT = BASE_DIR + '/media/' +MEDIA_URL = '/media/' diff --git a/back_latienda/urls.py b/back_latienda/urls.py index 14df475..9149eac 100644 --- a/back_latienda/urls.py +++ b/back_latienda/urls.py @@ -15,7 +15,10 @@ Including another URLconf """ from django.contrib import admin from django.urls import path +from django.conf.urls.static import static +from django.conf import settings + urlpatterns = [ path('admin/', admin.site.urls), -] +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/companies/models.py b/companies/models.py index 71a8362..b84a273 100644 --- a/companies/models.py +++ b/companies/models.py @@ -1,3 +1,38 @@ -from django.db import models +# from django.db import models +from django.contrib.gis.db import models # Create your models here. + +class Company(models.Model): + + WOO_COMMERCE = 'WOO_COMMERCE' + SHOPIFY = 'SHOPIFY' + PRESTASHOP = 'PRESTASHOP' + + PLATFORMS = ( + (WOO_COMMERCE, 'WooCommerce'), + (SHOPIFY, 'Shopify'), + (PRESTASHOP, 'Prestashop'), + ) + + cif = models.CharField('CIF', max_length=10, null=True, blank=True) + company_name = models.CharField('Razón Social Cooperativa', max_length=1000, null=True, blank=True) + short_name = models.CharField('Apócope', max_length=100, null=True, blank=True) # autogenerar si blank + web_link = models.URLField('Enlace a la web', null=True, blank=True) + shop = models.BooleanField('Tienda Online', null=True, default=False) + shop_link = models.URLField('Enlace a la tienda', null=True, blank=True) + platform = models.CharField('Plataforma de tienda online', choices=PLATFORMS, max_length=25, null=True, blank=True) + email = models.EmailField('Email', null=True, blank=True) + logo = models.ImageField('Logo', upload_to='logos/', null=True, blank=True) + # city = models.ForeignKey('geo.City', null=True, blank=True, on_delete=models.DO_NOTHING) + address = models.CharField('Dirección', max_length=1000, null=True, blank=True) + geo = models.PointField('Coordenadas', null=True, blank=True ) + phone = models.CharField('Teléfono', max_length=25, null=True, blank=True) + mobile = models.CharField('Teléfono móvil', max_length=25, null=True, blank=True) + other_phone = models.CharField('Otro teléfono', max_length=25, null=True, blank=True) + description = models.TextField('Descripción de la cooperativa', null=True, blank=True) + shop_rss_feed = models.URLField('RSS tienda online', null=True, blank=True) + sale_terms = models.TextField('Condiciones de venta', null=True, blank=True) + shipping_cost = models.DecimalField('Gastos de envío', max_digits=10, decimal_places=2, null=True, blank=True) + # tags + sync = models.BooleanField('Sincronizar tienda', default=False, null=True, blank=True) diff --git a/media/.gitignore b/media/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/media/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file