alexandersimoes/dataviva — pull request #38 by mariohmol (2014-02-04 18:15:49+00:00)
Title: Email contacts and type in Ask About

Guys,

here we have some commit that aims to:

1. Improved some perfomance issues, mostly regarded to get user in session
* it has a problem that a single page was doing get user by ID many times

2. Inserted at Utils.py a function to take black terms in a text

3. Included flask-mail module and a function to be used as a send mailer

4. Now there is some emails send's to adminstrator and users, when their posts had been responded.

5. User profile now has a button to not receive any notification by email

6. For security reasons we included roles to prevent bad users in admin section

It's necessary to run these scripts:
ALTER TABLE account_user ADD COLUMN agree_mailer TINYINT(1) DEFAULT 1;

DROP TABLE IF EXISTS `ask_type`;

CREATE TABLE `ask_type` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(200) DEFAULT NULL,
`name_en` varchar(200) DEFAULT NULL,
`name_pt` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `ask_type` (`id`, `name`, `name_en`, `name_pt`)
VALUES
(1,'question','Question','Pergunta'),
(2,'comment','Comment','Comentário'),
(3,'contact','Contact','Contato');

ALTER TABLE ask_question ADD COLUMN type_id INTEGER;

ALTER TABLE `ask_question`
ADD CONSTRAINT `ask_question_ibfk_3`
FOREIGN KEY (`type_id` )
REFERENCES `ps`.`ask_type` (`id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION
, ADD INDEX `ask_question_ibfk_3_idx` (`type_id` ASC) ;