-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
368 changed files
with
27,351 additions
and
2,067 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,14 @@ | |
from models import Comment | ||
from models import Invite | ||
from models import Event | ||
from models import Feature | ||
from utils import NotAuthorizedException | ||
from google.appengine.ext import ndb | ||
from google.appengine.api import search | ||
|
||
INDEX_INSTITUTION = 'institution' | ||
INDEX_USER = 'user' | ||
INDEX_EVENT = 'event' | ||
TEXT = 'At vero eos et accusamus et iusto odio dignissimos \ | ||
ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti \ | ||
quos dolores et quas molestias excepturi sint occaecati cupiditate \ | ||
|
@@ -37,6 +39,22 @@ | |
delectus, ut aut reiciendis voluptatibus maiores alias consequatur \ | ||
aut perferendis doloribus asperiores repellat.' | ||
|
||
features = [ | ||
{ | ||
"name": 'manage-inst-edit', | ||
"enable_mobile": "DISABLED", | ||
"enable_desktop": "ALL", | ||
"translation_dict": { | ||
"pt-br": "Editar informações da instituição" | ||
} | ||
} | ||
] | ||
|
||
def create_features(): | ||
for feature in features: | ||
if not Feature.get_by_id(feature['name']): | ||
Feature.create(**feature) | ||
|
||
|
||
def add_comments_to_post(user, user_reply, post, institution, comments_qnt=3): | ||
"""Add comments to post.""" | ||
|
@@ -165,7 +183,8 @@ def clear_data_store(): | |
delete_all_in_index(index_institution) | ||
index_user = search.Index(name=INDEX_USER) | ||
delete_all_in_index(index_user) | ||
|
||
index_event = search.Index(name=INDEX_EVENT) | ||
delete_all_in_index(index_event) | ||
|
||
class BaseHandler(webapp2.RequestHandler): | ||
"""Base Handler.""" | ||
|
@@ -313,7 +332,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', | ||
|
@@ -520,11 +539,55 @@ def get(self): | |
splab.posts = [] | ||
splab.put() | ||
|
||
create_features() | ||
|
||
jsonList.append({"msg": "database initialized with a few posts"}) | ||
|
||
self.response.write(json.dumps(jsonList)) | ||
|
||
class CreateFeaturesHandler(BaseHandler): | ||
def get(self): | ||
create_features() | ||
self.response.write({"msg": "database initialized with a few features"}) | ||
|
||
|
||
class UpdateHandler(BaseHandler): | ||
"""Temporary handler. | ||
It handles with the entities update for some attributes. | ||
""" | ||
|
||
def get(self): | ||
"""Retrieve all users and institutions to | ||
create their new attributes avoiding an error in production. | ||
""" | ||
from datetime import datetime | ||
|
||
users = User.query().fetch() | ||
|
||
for user in users: | ||
user.last_seen_institutions = datetime.now() | ||
user.put() | ||
|
||
existing_institutions = Institution.query().fetch() | ||
|
||
for institution in existing_institutions: | ||
institution.creation_date = datetime.now() | ||
institution.put() | ||
|
||
existing_events = Event.query().fetch() | ||
|
||
for event in existing_events: | ||
event.put() | ||
|
||
self.response.write("worked") | ||
|
||
|
||
|
||
app = webapp2.WSGIApplication([ | ||
('/admin/reset', ResetHandler), | ||
('/admin/create-features', CreateFeaturesHandler), | ||
('/admin/update', UpdateHandler) | ||
], debug=True) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"""Not Allowed Exception.""" | ||
|
||
__all__ = ['NotAllowedException'] | ||
|
||
class NotAllowedException(Exception): | ||
"""Not Allowed Exception.""" | ||
|
||
def __init__(self, msg=None): | ||
"""Init method.""" | ||
super(NotAllowedException, self).__init__(msg or 'Operation not allowed.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Event Followers Handler.""" | ||
import json | ||
from google.appengine.ext import ndb | ||
|
||
from models import Event | ||
from utils import Utils | ||
from util import login_required | ||
from utils import NotAuthorizedException | ||
from utils import json_response | ||
from . import BaseHandler | ||
|
||
__all__ = ['EventFollowersHandler'] | ||
|
||
class EventFollowersHandler(BaseHandler): | ||
"""Event Followers Handler.""" | ||
|
||
@json_response | ||
@login_required | ||
def post(self, user, event_urlsafe): | ||
""".""" | ||
event = ndb.Key(urlsafe=event_urlsafe).get() | ||
|
||
Utils._assert(event.state != 'published', | ||
'The event is not published', | ||
NotAuthorizedException) | ||
|
||
event.add_follower(user) | ||
|
||
@json_response | ||
@login_required | ||
def delete(self, user, event_urlsafe): | ||
""".""" | ||
event = ndb.Key(urlsafe=event_urlsafe).get() | ||
|
||
Utils._assert(event.state != 'published', | ||
'The event is not published', | ||
NotAuthorizedException) | ||
|
||
event.remove_follower(user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.