Skip to content

Commit

Permalink
Merge pull request #1521 from eciis/responsive
Browse files Browse the repository at this point in the history
Merge Responsive - dev
  • Loading branch information
Luiz-FS authored Mar 11, 2019
2 parents 3f3a85a + 24210bf commit 2a31ec1
Show file tree
Hide file tree
Showing 45 changed files with 1,060 additions and 156 deletions.
2 changes: 1 addition & 1 deletion backend/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def get(self):
'address': address_key,
'actuation_area': 'GOVERNMENT_AGENCIES',
'description': 'Ministério da Saúde',
'photo_url': 'https://i1.wp.com/notta.news/wp-content/uploads/2017/08/tbg_20170713080909_62787.jpg?w=1024',
'photo_url': 'https://firebasestorage.googleapis.com/v0/b/development-cis.appspot.com/o/images%2Fministerio_da_saude_logo-1551970633722?alt=media&token=a658e366-a3b6-4699-aa98-95dc79eff3b5',
'email': '[email protected]',
'phone_number': '61 3315-2425',
'state': 'active',
Expand Down
4 changes: 3 additions & 1 deletion backend/handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from .institution_children_handler import *
from .event_followers_handler import *
from .feature_toggle_handler import *
from .current_state_email_request_handler import *

handlers = [
base_handler, erro_handler, event_collection_handler, event_handler,
Expand All @@ -63,7 +64,8 @@
user_request_collection_handler, user_timeline_handler, vote_handler,
invite_hierarchy_collection_handler, invite_user_collection_handler,
invite_institution_handler, invite_user_handler, institution_parent_handler,
institution_children_handler, event_followers_handler, feature_toggle_handler
institution_children_handler, event_followers_handler, feature_toggle_handler,
current_state_email_request_handler
]

__all__ = [prop for handler in handlers for prop in handler.__all__]
29 changes: 29 additions & 0 deletions backend/handlers/current_state_email_request_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
"""Current state link request email handler."""

import json

from util import login_required
from utils import json_response
from . import BaseHandler
from send_email_hierarchy import RequestStateEmailSender

__all__ = ['CurrentStateEmailRequestHandler']


class CurrentStateEmailRequestHandler(BaseHandler):
"""Current state email request handler."""

@login_required
@json_response
def post(self, user):
body = json.loads(self.request.body)

subject = "Link para preenchimento de formulario"

email_sender = RequestStateEmailSender(**{
'receiver': user.email,
'subject': subject,
'body': body
})
email_sender.send_email()
4 changes: 2 additions & 2 deletions backend/handlers/event_collection_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def get_filtered_events(filters, user):
december = month == 12
begin_selected_month_utc = datetime(year, month, 1, 3)
end_selected_month_utc = datetime(year if not december else year+1, month+1 if not december else 1, 1, 3)
query = ndb.gql("SELECT __key__ FROM Event WHERE institution_key IN :1 AND state =:2 AND start_time < DATETIME(:3)",
user.follows, 'published', end_selected_month_utc.strftime("%Y-%m-%d %H:%M:%S"))
query = ndb.gql("SELECT __key__ FROM Event WHERE institution_key IN :1 AND start_time < DATETIME(:2)",
user.follows, end_selected_month_utc.strftime("%Y-%m-%d %H:%M:%S"))
if query.count() > 0:
return ndb.gql("SELECT * FROM Event WHERE __key__ IN :1 AND end_time >= DATETIME(:2)",
query.fetch(), begin_selected_month_utc.strftime("%Y-%m-%d %H:%M:%S")).order(Event.end_time, Event.key)
Expand Down
2 changes: 2 additions & 0 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from handlers import InstitutionChildrenHandler
from handlers import EventFollowersHandler
from handlers import FeatureToggleHandler
from handlers import CurrentStateEmailRequestHandler

methods = set(webapp2.WSGIApplication.allowed_methods)
methods.add('PATCH')
Expand Down Expand Up @@ -100,6 +101,7 @@
("/api/user/timeline.*", UserTimelineHandler),
("/api/search/institution", SearchHandler),
("/api/feature-toggle.*", FeatureToggleHandler),
("/api/email/current-state", CurrentStateEmailRequestHandler),
("/login", LoginHandler),
("/logout", LogoutHandler),
("/api/.*", ErroHandler)
Expand Down
5 changes: 3 additions & 2 deletions backend/send_email_hierarchy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
from .request_link_email_sender import *
from .request_user_email_sender import *
from .transfer_admin_email_sender import *

from .request_state_email_sender import *

email_modules = [
email_sender, request_institution_email_sender, invite_institution_email_sender,
invite_user_email_sender, leave_institution_email_sender,
remove_institution_email_sender, remove_member_email_sender,
request_link_email_sender, request_user_email_sender, transfer_admin_email_sender
request_link_email_sender, request_user_email_sender, transfer_admin_email_sender,
request_state_email_sender
]

__all__ = [prop for email_module in email_modules for prop in email_module.__all__]
35 changes: 35 additions & 0 deletions backend/send_email_hierarchy/request_state_email_sender.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
"""Request state email sender."""

from . import EmailSender

__all__ = ['RequestStateEmailSender']


class RequestStateEmailSender(EmailSender):
"""Entity responsible to send state link email."""

def __init__(self, **kwargs):
"""The class constructor.
It initializes the object with its html and its specific properties.
"""
super(RequestStateEmailSender, self).__init__(**kwargs)
self.subject = "Link para preenchimento de formulario"
self.html = "request_state_email.html"

def send_email(self):
"""It enqueue a sending email task with the json that will fill the entity's html.
For that, it call its super with email_json property.
"""
email_json = {
'state_link': self.__get_state_link()
}
super(RequestStateEmailSender, self).send_email(email_json)

def __get_state_link(self):
return self.__get_data()['state-link']

def __get_data(self):
return self.body['data']
120 changes: 120 additions & 0 deletions backend/templates/request_state_email.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<title></title>
</head>

<body style="margin:0; padding:0;">
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr align="center">
<td align="center">

<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" style="background-color: #004D40;">
<tr align="center">
<td>
<img src="https://firebasestorage.googleapis.com/v0/b/eciis-splab.appspot.com/o/admin_email%2FLOGo.png?alt=media&token=fbb74261-4b24-42aa-b67f-be36577c48df"
style="width: 50px; padding-top: 20px; height: 50px;" />
<img src="https://firebasestorage.googleapis.com/v0/b/eciis-splab.appspot.com/o/admin_email%2Fasset_09_logo_white.png?alt=media&token=5fa33bc3-140a-4f71-90ff-5d1e9203a196"
style="width: 150px; padding-bottom: 10px;" />
</td>
</tr>
</table>

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
<div style="height: 410px;">
<div style="background-color: #009688; height: 65%;" align="center">
<div style="height: 25%; background-color: #004D40;">
<div style="width: 275px; height: 470px; margin-top: 10px; border: 1px solid #E1E1E1; background: #fff;
border-radius: 5px; display: inline-block; position: relative;" align="center">
<div style="height: 35%; background-color: #EEEEEE; border-top-left-radius: 10px; border-top-right-radius: 10px;">
<img src="https://firebasestorage.googleapis.com/v0/b/eciis-splab.appspot.com/o/admin_email%2FAsset%2012logo.png?alt=media&token=9b5b92e9-c889-4176-b80a-c37afc59af4b"
style="width: 100px; margin-top: 40px;" />
</div>
<div style="background-color: white; font-size: 20px;">
<div style="width: 90%; color: #009688; margin-top: 10px; font-family: Arial, Helvetica, sans-serif;">
<b>AQUI ESTÁ O LINK QUE VOCÊ SOLICITOU</b>
</div>
<hr width="80%;" />
<div style="color: #757575; width: 90%; font-size: 15px; margin-top: 10px; font-family: Arial, Helvetica, sans-serif; word-wrap: break-word;">
<b>
VOCÊ SOLICITOU O LINK DE UM FORMULARIO DA PLATAFORMA PARA PREENCHE-LO DEPOIS E AQUI ESTÁ ELE. CLIQUE NO BOTÃO ABAIXO PARA ACESSA-LO.
</b>
</div>
<div style="margin-top: 10px;">
<a href="{{ state_link }}" style="text-decoration: none;">
<button style="background-color: #009688; width: 90%; height: 25px; border: none;">
<span style="text-align: center; font-size: 8px; color: #FFFFFF">Acessar link</span>
</button>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</td>
</tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" style="margin-bottom: 5px; margin-top: 80px;">
<tr align="center">
<td>
<img src="https://firebasestorage.googleapis.com/v0/b/eciis-splab.appspot.com/o/admin_email%2FLOGo.png?alt=media&token=fbb74261-4b24-42aa-b67f-be36577c48df"
style="width: 50px; height: 50px;" />
<img src="https://firebasestorage.googleapis.com/v0/b/eciis-splab.appspot.com/o/admin_email%2FAsset_09LOGO.png?alt=media&token=a33e8fc2-95d4-4b74-ae95-c6f50514645e"
style="width: 150px; padding-bottom: 10px;">
</td>
</tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr align="center">
<td style="width: 100%;">
<div style="width: 100%; height: 170px; position: relative; border-top: 1px solid #E0E0E0; border-bottom: 1px solid #E1E1E1; background: #fff;
border-radius: 0px;
display: inline-block; position: relative;" align="center">
<div style="height: 50%; background-color: white;">
<div>
<img src="https://firebasestorage.googleapis.com/v0/b/eciis-splab.appspot.com/o/admin_email%2Fufcg.png?alt=media&token=6edbaf3e-3c46-4e8a-8101-80d432d1ab6f"
style="width: 100px; margin-top: 5px;" />
<img src="https://firebasestorage.googleapis.com/v0/b/eciis-splab.appspot.com/o/admin_email%2Fcis.png?alt=media&token=ccab7007-97b0-462b-a1d0-38b5da58a2ad"
style="width: 100px; margin-top: 5px; margin-left: 20px;" />
</div>
<div>
<img src="https://firebasestorage.googleapis.com/v0/b/eciis-splab.appspot.com/o/admin_email%2Fopasoms.png?alt=media&token=a71b5c27-a317-417e-aa6e-3c744ed0e602"
style="width: 220px; margin-top: 5px;" />
</div>
<div>
<img src="https://firebasestorage.googleapis.com/v0/b/eciis-splab.appspot.com/o/admin_email%2Flogo_ms_nova.png?alt=media&token=11b3f998-309e-46aa-bfa6-3f02ad4ec679"
style="width: 150px; margin-top: 10px;" />
</div>
<div style="margin-top: 23px; font-size: 10px;">
<span align="center" style="word-break: break-all; color: black;">
Copyright © 2017 Plataforma CIS - Ministério da Saúde.
</span>
</div>
<div>
<span style="font-size: 10px; color: black;">
Todos os direitos reservados.
</span>
</div>
</div>
<div style="height: 50%; background-color: white;">
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>

</html>
24 changes: 24 additions & 0 deletions frontend/email/EmailService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(function () {
'use strict';

angular.module("app").service('EmailService', ["HttpService", function emailService(HttpService) {
const emailService = this;

emailService.STATE_LINK_EMAIL_API_URI = "/api/email/current-state";

/**
* Make a post request to the backend to send a state link by email.
* It receives the state link that will be sent.
*
* @param stateLink the state link that will be sent.
* @returns The post request to the backend.
*/
emailService.sendStateLink = (stateLink) => {
return HttpService.post(emailService.STATE_LINK_EMAIL_API_URI, {
"data": {
"state-link": Config.FRONTEND_URL + stateLink
}
});
};
}]);
})();
43 changes: 43 additions & 0 deletions frontend/email/stateLinkRequest/StateLinkRequestService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
(function () {
'use strict';

angular.module("app").service('StateLinkRequestService', ['$mdDialog', function StateLinkRequestService($mdDialog) {
const StateLinkRequestService = this;

/**
* It shows a dialog that will ask the user if it wants to receive the link of the state
* by email. It is used in pages that has big forms to be filled.
*
* @param stateLink the state link that will be sent by email.
* @param previousState the state that the user will comeback if it accepts to receive
* the email.
*/
StateLinkRequestService.showLinkRequestDialog = (stateLink, previousState) => {
$mdDialog.show({
templateUrl: "app/email/stateLinkRequest/stateLinkRequestDialog.html",
clickOutsideToClose:true,
locals: {
stateLink: stateLink,
previousState: previousState,
},
controller: [
'EmailService',
'$state',
'stateLink',
'previousState',
StateLinkRequestController,
],
controllerAs: 'ctrl'
});
};

function StateLinkRequestController(EmailService, $state, stateLink, previousState) {
const ctrl = this;

ctrl.sendStateLink = () => {
EmailService.sendStateLink(stateLink);
$state.go(previousState);
};
}
}]);
})();
9 changes: 9 additions & 0 deletions frontend/email/stateLinkRequest/stateLinkConstants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(function () {
'use strict';

angular.module("app").constant('STATE_LINKS', {
'CREATE_EVENT': '/events',
'MANAGE_INSTITUTION': '/institution/INSTITUTION_KEY/edit',
'INVITE_INSTITUTION': '/inviteInstitution'
});
})();
9 changes: 9 additions & 0 deletions frontend/email/stateLinkRequest/stateLinkRequestDialog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<md-dialog>
<gen-dialog
title="Formulário extenso"
subtitle="Você está prestes a acessar um formulario longo, por isso, é recomendado preenche-lo ou modifica-lo em um computador. Você deseja receber um email com o link desse formulario para preenche-lo mais tarde?"
confirm-action="ctrl.sendStateLink"
cancel-text="Não"
confirm-text="Sim">
</gen-dialog>
</md-dialog>
27 changes: 27 additions & 0 deletions frontend/event/canceledEventHeader.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use strict";

(function() {

function CanceledEventController() {
const canceledEventCtrl = this;

/**
* Get the first name of who modified the event by last
*/
canceledEventCtrl.getNameOfLastModified = () => {
return _.first(canceledEventCtrl.event.last_modified_by.split(" "));
};

};

angular
.module("app")
.component("canceledEventHeader", {
templateUrl: 'app/event/canceled_event_header.html',
controller: [CanceledEventController],
controllerAs: 'canceledEventCtrl',
bindings: {
event: '<',
}
});
})();
8 changes: 8 additions & 0 deletions frontend/event/canceled_event_header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<span layout="row">
<md-icon class="event-canceled-icon">highlight_off</md-icon>
<div>
<h5 class="event-canceled-tag">ESTE EVENTO FOI CANCELADO</h5>
<h6 class="event-canceled-subtitle">por {{canceledEventCtrl.getNameOfLastModified()}} &bull;
{{canceledEventCtrl.event.last_modified_date | amUtc | amLocal | amCalendar:referenceTime:formats}} </h6>
</div>
</span>
Loading

0 comments on commit 2a31ec1

Please sign in to comment.