Example #1
0
def pending_intake_page(request, id):
    # Fetch the data.
    template_url = 'tenant_intake/pending_intake.html'
    intake = get_object_or_404(Intake, pk=int(id))
    url =  resolve_full_url_with_subdmain(
        request.tenant.schema_name,
        'tenant_intake_employee_pending_details',
        [intake.id]
    )
    web_view_extra_url = resolve_full_url_with_subdmain(
        request.tenant.schema_name,
        'foundation_email_pending_intake',
        [intake.id,]
    )

    # Run a security check to verify that the authenticated User is an employee
    # of the Organization.
    if not request.tenant_me.is_employee():
        raise PermissionDenied

    # Render our email templated message.
    return render(request, template_url,{
        'user': request.user,
        'intake': intake,
        'url': url,
        'web_view_url': web_view_extra_url
    })
Example #2
0
def rejected_intake_page(request, id):
    # Fetch the data.
    template_url = 'tenant_intake/rejected_intake.html'
    intake = get_object_or_404(Intake, pk=int(id))
    url =  resolve_full_url_with_subdmain(
        request.tenant.schema_name,
        'foundation_auth_user_login',
        []
    )
    web_view_extra_url = resolve_full_url_with_subdmain(
        request.tenant.schema_name,
        'foundation_email_rejected_intake',
        [intake.id,]
    )

    # Run a security check to verify that the authenticated User belongs to
    # the the Intake.
    if request.user != intake.me.owner:
        raise PermissionDenied

    # Render our email templated message.
    return render(request, template_url, {
        'user': request.user,
        'intake': intake,
        'url': url,
        'web_view_url': web_view_extra_url
    })
Example #3
0
def calendar_pending_event_page(request, calendar_event_id):
    # Fetch the data.
    template_url = 'tenant_calendar/pending_invite.html'
    calendar_event = get_object_or_404(CalendarEvent, pk=int(calendar_event_id))
    url =  resolve_full_url_with_subdmain(
        request.tenant.schema_name,
        'tenant_calendar_details_info',
        [calendar_event.id,]
    )
    web_view_extra_url = resolve_full_url_with_subdmain(
        request.tenant.schema_name,
        'foundation_email_calendar_pending_event',
        [calendar_event.id,]
    )

    # # Run a security check to make sure the authenticated User is a
    # # participant in the conversation.
    # if request.tenant_me not in task.participants.all():
    #     raise PermissionDenied

    # Render our email templated message.
    return render(request, template_url,{
        'user': request.user,
        'me': request.tenant_me,
        'calendar_event': calendar_event,
        'url': url,
        'web_view_url': web_view_extra_url
    })
Example #4
0
def task_page(request, task_id, log_event_id):
    # Fetch the data.
    template_url = 'tenant_task/task.html'
    task = get_object_or_404(Task, pk=int(task_id))
    log_event = get_object_or_404(SortedLogEventByCreated, pk=int(log_event_id))
    url =  resolve_full_url_with_subdmain(
        request.tenant.schema_name,
        'tenant_task_details_info',
        [task.id,]
    )
    web_view_extra_url = resolve_full_url_with_subdmain(
        request.tenant.schema_name,
        'foundation_email_task',
        [task.id, log_event.id,]
    )

    # Run a security check to make sure the authenticated User is a
    # participant in the conversation.
    if request.tenant_me not in task.participants.all():
        raise PermissionDenied

    # Render our email templated message.
    return render(request, template_url,{
        'user': request.user,
        'task': task,
        'log_event': log_event,
        'url': url,
        'web_view_url': web_view_extra_url
    })
Example #5
0
def message_page(request, id):
    # Fetch the data.
    template_url = 'tenant_message/message.html'
    message = get_object_or_404(Message, pk=int(id))
    url =  resolve_full_url_with_subdmain(
        request.tenant.schema_name,
        'tenant_conversation',
        [message.sender.id,]
    )
    web_view_extra_url = resolve_full_url_with_subdmain(
        request.tenant.schema_name,
        'foundation_email_message',
        [message.id,]
    )

    # Run a security check to make sure the authenticated User is a
    # participant in the conversation.
    if request.tenant_me not in message.participants.all():
        raise PermissionDenied

    # Render our email templated message.
    return render(request, template_url,{
        'user': request.user,
        'message': message,
        'url': url,
        'web_view_url': web_view_extra_url
    })
    def send_pending_document_review_notification(self, document):
        """
        Function will send a "Pending Document Review" email to the Documents
        assigned Advisor.
        """
        # Fetch the original administrator for this Organization.
        org_admin_user = User.objects.filter(
            groups__id=constants.ORGANIZATION_ADMIN_GROUP_ID).earliest(
                'date_joined')

        # Iterate through all owners of this document and generate the contact
        # list for all the Advisors for each Entrepreneur.
        contact_list = []
        for me in document.workspace.mes.all():
            # If this User profile has an assigned manager then add this person
            # to the email else just email the administrator.
            if me.managed_by:
                contact_list.append(me.managed_by.owner.email)
            else:
                contact_list.append(org_admin_user.email)

                # Assign the original admininistrator User to this unmanaged user.
                me.managed_by = Me.objects.get(owner=org_admin_user)
                me.save()

        # Generate the data.
        url = resolve_full_url_with_subdmain(self.request.tenant.schema_name,
                                             'tenant_review_detail', [
                                                 document.id,
                                             ])
        web_view_extra_url = resolve_full_url_with_subdmain(
            self.request.tenant.schema_name,
            'foundation_email_pending_document', [
                document.id,
            ])
        subject = "Pending Document Review"
        param = {
            'user': self.request.user,
            'document': document,
            'url': url,
            'web_view_url': web_view_extra_url,
        }

        # Plug-in the data into our templates and render the data.
        text_content = render_to_string('tenant_review/pending_doc_review.txt',
                                        param)
        html_content = render_to_string(
            'tenant_review/pending_doc_review.html', param)

        # Generate our address.
        from_email = env_var('DEFAULT_FROM_EMAIL')
        to = contact_list

        # Send the email.
        msg = EmailMultiAlternatives(subject, text_content, from_email, to)
        msg.attach_alternative(html_content, "text/html")
        msg.send()
Example #7
0
    def send_pending_document_review_notification(self, schema_name, document):
        """
        Function will send a "Pending Document Review" email to the Documents
        assigned Advisor.
        """
        # Iterate through all owners of this document and generate the contact
        # list for all the Advisors for each Entrepreneur.
        contact_list = []
        for me in document.workspace.mes.all():
            if me.managed_by:
                # If this User profile has an assigned manager then add this person
                # to the email else just email the administrator.
                contact_list.append(me.managed_by.owner.email)

        if len(contact_list) == 0:
            admins = User.objects.filter(groups__id=constants.ORGANIZATION_ADMIN_GROUP_ID)
            for admin in admins.all():
                # Attach the email to the contact_list.
                contact_list.append(admin.email)

        # Generate the data.
        url =  resolve_full_url_with_subdmain(
            schema_name,
            'tenant_review_detail',
            [document.id,]
        )
        web_view_extra_url = resolve_full_url_with_subdmain(
            schema_name,
            'foundation_email_pending_document',
            [document.id,]
        )
        subject = "Pending Document Review"
        param = {
            'document': document,
            'url': url,
            'web_view_url': web_view_extra_url,
        }

        # Plug-in the data into our templates and render the data.
        text_content = render_to_string('tenant_review/pending_doc_review.txt', param)
        html_content = render_to_string('tenant_review/pending_doc_review.html', param)

        # Generate our address.
        from_email = settings.DEFAULT_FROM_EMAIL
        to = contact_list

        # Send the email.
        msg = EmailMultiAlternatives(subject, text_content, from_email, to)
        msg.attach_alternative(html_content, "text/html")
        msg.send()
    def begin_processing(self, schema_name, document):
        """
        Function will send a "Accepted Document Review" email to the Documents
        assigned Advisor.
        """
        # Iterate through all owners of this document and generate the contact
        # list for all the Entrepreneurs.
        contact_list = []
        for me in document.workspace.mes.all():
            contact_list.append(me.owner.email)

        # Generate the data.
        url = resolve_full_url_with_subdmain(schema_name,
                                             'foundation_auth_user_login', [])
        web_view_extra_url = resolve_full_url_with_subdmain(
            schema_name, 'foundation_email_accepted_document', [
                document.id,
            ])
        subject = "Accepted Document"
        param = {
            'document': document,
            'url': url,
            'web_view_url': web_view_extra_url,
        }

        # Plug-in the data into our templates and render the data.
        text_content = render_to_string(
            'tenant_review/accepted_doc_review.txt', param)
        html_content = render_to_string(
            'tenant_review/accepted_doc_review.html', param)

        # Generate our address.
        from_email = settings.DEFAULT_FROM_EMAIL
        to = contact_list

        # Send the email.
        msg = EmailMultiAlternatives(subject, text_content, from_email, to)
        msg.attach_alternative(html_content, "text/html")
        msg.send()

        # Return a success message to the console.
        self.stdout.write(
            self.style.SUCCESS(
                _('Sent Document #%s judgement email.') % str(document.id)))
Example #9
0
def accepted_document_page(request, document_id):
    # Fetch the data.
    template_url = 'tenant_review/accepted_doc_review.html'
    document = get_object_or_404(Document, pk=int(document_id))
    url =  resolve_full_url_with_subdmain(
        request.tenant.schema_name,
        'foundation_auth_user_login',
        []
    )
    web_view_extra_url = resolve_full_url_with_subdmain(
        request.tenant.schema_name,
        'foundation_email_accepted_document',
        [document.id,]
    )

    # Render our email templated message.
    return render(request, template_url,{
        'user': request.user,
        'document': document,
        'url': url,
        'web_view_url': web_view_extra_url,
    })