From 444d364f1a3bd1384356fdc808971165523e6fd4 Mon Sep 17 00:00:00 2001 From: David Arranz Date: Wed, 14 Jun 2023 19:34:58 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1adir=20Time=20Zone=20a=20los=20Venues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/venues/venue.model.js | 131 +++++++++++++++------------- modules/venues/venue.validations.js | 25 +++--- 2 files changed, 82 insertions(+), 74 deletions(-) diff --git a/modules/venues/venue.model.js b/modules/venues/venue.model.js index 160eee4..2fa10f8 100644 --- a/modules/venues/venue.model.js +++ b/modules/venues/venue.model.js @@ -1,68 +1,75 @@ -'use strict'; +"use strict"; -const cdnHelper = require('../../helpers/cdn.helper'); +const cdnHelper = require("../../helpers/cdn.helper"); module.exports = function (sequelize, DataTypes) { - const Venue = sequelize.define('Venue', { - id: { - type: DataTypes.UUID, - defaultValue: DataTypes.UUIDV4, - primaryKey: true, + const Venue = sequelize.define( + "Venue", + { + id: { + type: DataTypes.UUID, + defaultValue: DataTypes.UUIDV4, + primaryKey: true, + }, + name: { + type: DataTypes.STRING, + allowNull: false, + }, + description: { + type: DataTypes.STRING, + }, + address: { + type: DataTypes.STRING, + allowNull: false, + }, + city: { + type: DataTypes.STRING, + allowNull: false, + }, + country: { + type: DataTypes.STRING, + }, + state: { + type: DataTypes.STRING, + }, + postal_code: { + type: DataTypes.STRING, + }, + accessibility: { + type: DataTypes.STRING, + }, + gmt: { + type: DataTypes.INTEGER, + allowNull: false, + defaultValue: 1, + }, + latitude: { + type: DataTypes.DECIMAL(10, 8), + }, + longitude: { + type: DataTypes.DECIMAL(11, 8), + }, + image_url: { + type: DataTypes.VIRTUAL, + get: function () { + const city = this.get("city"); + return cdnHelper.getCDNCityMediaUrl(city); }, - name: { - type: DataTypes.STRING, - allowNull: false, - }, - description: { - type: DataTypes.STRING, - }, - address: { - type: DataTypes.STRING, - allowNull: false, - }, - city: { - type: DataTypes.STRING, - allowNull: false, - }, - country: { - type: DataTypes.STRING, - }, - state: { - type: DataTypes.STRING, - }, - postal_code: { - type: DataTypes.STRING, - }, - accessibility: { - type: DataTypes.STRING, - }, - gmt: { - type: DataTypes.INTEGER, - allowNull: false, - defaultValue: 1, - }, - latitude: { - type: DataTypes.DECIMAL(10, 8), - }, - longitude: { - type: DataTypes.DECIMAL(11, 8), - }, - image_url: { - type: DataTypes.VIRTUAL, - get: function () { - const city = this.get('city'); - return cdnHelper.getCDNCityMediaUrl(city) - } - } - }, { - tableName: 'venues', - freezeTableName: true, - timestamps: true, - }); + }, + tz: { + type: DataTypes.STRING, + }, + }, + { + tableName: "venues", + freezeTableName: true, + timestamps: true, + } + ); - Venue.associate = function (models) { - Venue.Events = Venue.hasMany(models.Event, { foreignKey: 'venueId', as: 'events' }); - }; + Venue.associate = function (models) { + Venue.Events = Venue.hasMany(models.Event, { foreignKey: "venueId", as: "events" }); + }; - return Venue; -}; \ No newline at end of file + return Venue; +}; diff --git a/modules/venues/venue.validations.js b/modules/venues/venue.validations.js index 83f649a..c1fb221 100644 --- a/modules/venues/venue.validations.js +++ b/modules/venues/venue.validations.js @@ -1,15 +1,16 @@ -const Joi = require('joi'); +const Joi = require("joi"); const VenueInputType = Joi.object().keys({ - name: Joi.string().required(), - address: Joi.string().required(), - city: Joi.string().required(), - gmt: Joi.number().min(-12).max(+12), - description: Joi.string().optional(), - country: Joi.string().optional(), - state: Joi.string().optional(), - postal_code: Joi.string().optional(), - accessibility: Joi.string().optional() + name: Joi.string().required(), + address: Joi.string().required(), + city: Joi.string().required(), + gmt: Joi.number().min(-12).max(+12), + description: Joi.string().optional(), + country: Joi.string().optional(), + state: Joi.string().optional(), + postal_code: Joi.string().optional(), + accessibility: Joi.string().optional(), + tz: Joi.string().optional(), }); /* const VenueOutputType = Joi.object().keys({ @@ -19,6 +20,6 @@ const VenueOutputType = Joi.object().keys({ */ module.exports = { - VenueInputType, -// VenueOutputType + VenueInputType, + // VenueOutputType };