How to use the intake.models.ApplicationLogEntry function in intake

To help you get started, we’ve selected a few intake examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codeforamerica / intake / intake / management / data_import.py View on Github external
def parse_log(self, record):
        if record['user'] in user_map:
            email = user_map[record['user']]
        else:
            email = record['user']
        return models.ApplicationLogEntry(
            time=gmt.localize(record['datetime']),
            user_id=self._email_pk_map.get(email, None),
            submission_id=self._uuid_pk_map.get(record['submission_key'], None),
            event_type=event_type_map[record['event_type']]
            )
github codeforamerica / intake / intake / models.py View on Github external
def from_logs(cls, logs):

        applicationLogEntryReference = {
            ApplicationLogEntry.OPENED: cls.OPENED,
            ApplicationLogEntry.REFERRED: cls.REFERRED,
            ApplicationLogEntry.PROCESSED: cls.PROCESSED,
            ApplicationLogEntry.DELETED: cls.DELETED,
            ApplicationLogEntry.CONFIRMATION_SENT: cls.CONFIRMATION_SENT,
            ApplicationLogEntry.REFERRED_BETWEEN_ORGS: cls.REFERRED_BETWEEN_ORGS,
        }

        events = []

        applicant_ids = dict(FormSubmission.objects.filter(
            pk__in=[log.submission_id for log in logs]
        ).values_list('id', 'applicant_id'))
        for log in logs:
            applicant_id = applicant_ids[log.submission_id]
            if applicant_id:
                event = cls(
github codeforamerica / intake / intake / management / data_import.py View on Github external
'''


from pytz import timezone

LOGS_SQL = '''
select * from form_filler_logentry where event_type != 'received';
'''

user_map = {
    'bgolder': 'bgolder@codeforamerica.org',
    'jazmyn': 'jazmyn@codeforamerica.org'
}

event_type_map = {
    'added': models.ApplicationLogEntry.PROCESSED,
    'opened': models.ApplicationLogEntry.OPENED,
    'referred': models.ApplicationLogEntry.REFERRED
}

gmt = timezone('GMT')

class DataImporter:

    def __init__(self, import_from='', ssl=False):
        config = dj_database_url.parse(import_from)
        self.config = dict(
            database=config.get('NAME', 'typeseam'),
            user=config.get('USER', 'postgres'),
            password=config.get('PASSWORD', ''),
            host=config.get('HOST', 'localhost'),
            port=config.get('PORT', 5432)
github codeforamerica / intake / intake / models.py View on Github external
def from_logs(cls, logs):

        applicationLogEntryReference = {
            ApplicationLogEntry.OPENED: cls.OPENED,
            ApplicationLogEntry.REFERRED: cls.REFERRED,
            ApplicationLogEntry.PROCESSED: cls.PROCESSED,
            ApplicationLogEntry.DELETED: cls.DELETED,
            ApplicationLogEntry.CONFIRMATION_SENT: cls.CONFIRMATION_SENT,
            ApplicationLogEntry.REFERRED_BETWEEN_ORGS: cls.REFERRED_BETWEEN_ORGS,
        }

        events = []

        applicant_ids = dict(FormSubmission.objects.filter(
            pk__in=[log.submission_id for log in logs]
        ).values_list('id', 'applicant_id'))
        for log in logs:
            applicant_id = applicant_ids[log.submission_id]
            if applicant_id:
                event = cls(
                    name=applicationLogEntryReference[log.event_type],
                    applicant_id=applicant_id,
                    data={
                        key: value for key, value in vars(log).items()
                        if key in [
github codeforamerica / intake / intake / models / form_submission.py View on Github external
def last_opened_by_agency(self):
        return self.agency_log_time(
            intake.models.ApplicationLogEntry.OPENED, max)
github codeforamerica / intake / intake / models / application_event.py View on Github external
def from_logs(cls, logs):
        LogEntry = intake.models.ApplicationLogEntry
        FormSubmission = intake.models.FormSubmission

        applicationLogEntryReference = {
            LogEntry.OPENED: cls.OPENED,
            LogEntry.REFERRED: cls.REFERRED,
            LogEntry.PROCESSED: cls.PROCESSED,
            LogEntry.DELETED: cls.DELETED,
            LogEntry.CONFIRMATION_SENT: cls.CONFIRMATION_SENT,
            LogEntry.REFERRED_BETWEEN_ORGS: cls.REFERRED_BETWEEN_ORGS,
        }

        events = []

        applicant_ids = dict(FormSubmission.objects.filter(
            pk__in=[log.submission_id for log in logs]
        ).values_list('id', 'applicant_id'))
github codeforamerica / intake / intake / models.py View on Github external
def from_logs(cls, logs):

        applicationLogEntryReference = {
            ApplicationLogEntry.OPENED: cls.OPENED,
            ApplicationLogEntry.REFERRED: cls.REFERRED,
            ApplicationLogEntry.PROCESSED: cls.PROCESSED,
            ApplicationLogEntry.DELETED: cls.DELETED,
            ApplicationLogEntry.CONFIRMATION_SENT: cls.CONFIRMATION_SENT,
            ApplicationLogEntry.REFERRED_BETWEEN_ORGS: cls.REFERRED_BETWEEN_ORGS,
        }

        events = []

        applicant_ids = dict(FormSubmission.objects.filter(
            pk__in=[log.submission_id for log in logs]
        ).values_list('id', 'applicant_id'))
        for log in logs:
            applicant_id = applicant_ids[log.submission_id]
            if applicant_id:
                event = cls(
                    name=applicationLogEntryReference[log.event_type],
                    applicant_id=applicant_id,
github codeforamerica / intake / intake / management / data_import.py View on Github external
from pytz import timezone

LOGS_SQL = '''
select * from form_filler_logentry where event_type != 'received';
'''

user_map = {
    'bgolder': 'bgolder@codeforamerica.org',
    'jazmyn': 'jazmyn@codeforamerica.org'
}

event_type_map = {
    'added': models.ApplicationLogEntry.PROCESSED,
    'opened': models.ApplicationLogEntry.OPENED,
    'referred': models.ApplicationLogEntry.REFERRED
}

gmt = timezone('GMT')

class DataImporter:

    def __init__(self, import_from='', ssl=False):
        config = dj_database_url.parse(import_from)
        self.config = dict(
            database=config.get('NAME', 'typeseam'),
            user=config.get('USER', 'postgres'),
            password=config.get('PASSWORD', ''),
            host=config.get('HOST', 'localhost'),
            port=config.get('PORT', 5432)
            )
github codeforamerica / intake / intake / views.py View on Github external
self.submissions = self.get_submissions_from_params(request)
        if not self.submissions:
            return not_allowed(request)

        self.submission_ids = [sub.id for sub in self.submissions]
        self.next_param = request.GET.get('next',
                                          reverse_lazy('intake-app_index'))
        self.log()
        self.modify_submissions()
        self.add_message()
        self.notify()
        return redirect(self.next_param)


class MarkProcessed(MarkSubmissionStepView):
    process_step = models.ApplicationLogEntry.PROCESSED

    def notify(self):
        notifications.slack_submissions_processed.send(
            **self.get_notification_context())


class ReferToAnotherOrgView(MarkSubmissionStepView):

    transfer_message_template = str(
        "You successfully transferred {applicant_name}'s application "
        "to {org_name}. You will no longer see their application."
    )

    def get_organization_id(self):
        return int(self.request.GET.get('to_organization_id'))