add countdown and some bug fixes like csv

This commit is contained in:
lefuturiste 2020-07-30 12:54:53 +00:00
parent 2b1e35e55f
commit d41551c806
18 changed files with 263 additions and 205 deletions

View file

@ -58,6 +58,7 @@ let main = async () => {
app.use(bodyParser.json())
app.get('/', PublicController.home)
app.get('/countdown', PublicController.countdown)
app.get('/association/:slug', PublicController.organization)
app.get('/a-propos', PublicController.about)
app.get('/mentions-legales', PublicController.legals)

View file

@ -24,6 +24,7 @@ export default class AdminOrganizationController {
// second column is always email
const input = req.body.data
const parsed = Papa.parse(input)
console.log(parsed)
if (parsed.errors.length > 0) {
return res
.status(400)
@ -51,7 +52,9 @@ export default class AdminOrganizationController {
console.log(errors)
res.status(400).json({
success: false,
errors
errors,
parsed,
input
})
})
}
@ -64,11 +67,12 @@ export default class AdminOrganizationController {
).then(({ data, body }) => {
res.json({ success: true, data, body })
}).catch((err: any) => {
res.status(400).json({ success: false, errors: err.errors })
res.status(400).json({ success: false, errors: [err] })
})
}
static storeUniversal(adminName: string, email: string, validationState: string): Promise<any> {
console.log(adminName, email, validationState)
return new Promise((resolve, reject) => {
if (validationState == null) {
validationState = 'unaware'

View file

@ -196,6 +196,7 @@ export default class DelegateController {
// before starting the upload process, we want to make sure that this organization is not exeeding the size limit for all the file
let currentSize = MediaService.computeSize(res.locals.organization.proposedVersion)
if (currentSize >= MediaService.getSizeLimit()) {
console.log('> An upload was refused because of a storage size exceed event')
return res
.status(413)
.json({
@ -274,9 +275,15 @@ export default class DelegateController {
// @ts-ignore
req.files.forEach((file: any) => {
proposedVersion.gallery.push(MediaService.buildMedia(file, 'media'))
file = MediaService.buildMedia(file, 'media')
proposedVersion.gallery.push(file)
// if the media is a video, we generate a thumbnail
if (file.contentType.indexOf('video') !== -1) {
console.log('generating a thumbnail')
}
})
Organization.updateOne({ _id: res.locals.organization._id }, {
proposedVersion,
updatedAt: new Date()

View file

@ -15,6 +15,10 @@ import MediaService from '../MediaService'
export default class PublicController {
static async countdown(req: express.Request, res: express.Response) {
res.render('countdown.twig', {})
}
static async home(req: express.Request, res: express.Response) {
// let client: IORedis.Redis = RedisService.getClient()
// await client.set('hello', 'world')

View file

@ -28,16 +28,13 @@ class AllowedString extends mongoose.SchemaType {
const email = {
type: String,
trim: true,
lowercase: true,
unique: true,
validate: {
validator: function(v: string) {
console.log(v)
return /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(v);
},
message: "Invalid email"
},
required: [true, "Email required"]
}
}
// @ts-ignore
@ -71,7 +68,7 @@ const OrganizationVersion = {
website: { type: String },
address: { type: String },
person: { type: String },
email: { type: String },
email,
phone: { type: String },
peoples: [{
name: { type: String },