Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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']]
)
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(
'''
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)
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 [
def last_opened_by_agency(self):
return self.agency_log_time(
intake.models.ApplicationLogEntry.OPENED, max)
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'))
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,
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)
)
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'))