Ejemplo n.º 1
0
    def post(self):
        if self.ensure_is_logged_in() and self.ensure_has_display_name():
            self.check_CSRF()
            user_id = self.user_id
            message_accept = self.request.get('accept')
            message_decline = self.request.get('decline')

            if message_accept:
                sender_id = EnkiModelMessage.get_by_id(
                    int(message_accept)).sender
                if sender_id:
                    EnkiModelFriends.add_friend(user_id, sender_id)
                    self.add_infomessage(
                        MSG.SUCCESS(),
                        MSG.FRIEND_ADDED(
                            EnkiModelDisplayName.get_display_name(sender_id)))
            elif message_decline:
                sender_id = EnkiModelMessage.get_by_id(
                    int(message_decline)).sender
                if sender_id:
                    EnkiModelMessage.remove_messages_crossed(
                        user_id, sender_id)

            self.render_tmpl('messages.html',
                             data=EnkiModelMessage.get_messages(self.user_id))
Ejemplo n.º 2
0
 def get(self):
     if self.ensure_is_logged_in() and self.ensure_has_display_name():
         self.render_tmpl('messages.html',
                          active_menu='profile',
                          data=EnkiModelMessage.get_messages(self.user_id))