Exemple #1
0
def referral_users():

    form = ReferralForm()

    if form.validate_on_submit():

        html = 'asdlkfjasfd'
        subject = 'REFFERAL: '
        admin = user_account.retrieve_user(1)

        email_parts = [
            html, subject, admin.email_address, form.email.data, None
        ]
        send_email(email_parts)

        value = [
            None, current_user.id, form.name.data, form.email.data,
            form.type.data, 'N'
        ]

        referral.add(value)

        flash('Referral has been sent!', 'success')
        return redirect(url_for('linkages.referral_users'))

    return render_template('/linkages/referral/index.html',
                           form=form,
                           active='referral')
Exemple #2
0
def confirm_linkage(token):

	id = confirm(token)

	if id=='bad':
		flash('Link already expired. Please contact the ReCOP Administrator.', 'error')
		return redirect(url_for('unregistered.index'))

	status = 'A'

	user = user_account.retrieve_user(id)

	if user.type==3:
		target='linkage'
	elif user.type==4:
		target='community'

	if id and user.status=='P':
		
		user_account.update_status(user.id, status)

		value = [None,user.id,user.id,target,2]
		audit_trail.add(value)

		flash("MOA acknowledged! Your account is now active.", 'success')

	else:
		
		flash("MOA already acknowledged. Please login.", 'info')
	
	return redirect(url_for('unregistered.login'))
Exemple #3
0
def event_signing(token, action):

	id = confirm(token)

	if id=='bad':
		flash('Link already expired. Please contact the ReCOP Administrator.', 'error')
		return redirect(url_for('unregistered.index'))

	event = event_views.show_info(id)
	organizer = user_information.linkage_info(event.organizer_id)
	success = user_account.retrieve_user(event.organizer_id)

	form = LoginForm()

	if form.validate_on_submit():

		user = user_account.login([form.username.data, form.password.data])

		if user and user.type==5:

			if action=='approve':

				if event.status=='A':
					if user.id==4:
						signatory = user_views.signatory_info(3)
						status='F'
					else:
						flash('Invalid credentials! Please try again.', 'error')	
						return redirect(url_for('unregistered.event_signing', token=token, action=action))
				elif event.status=='F':
					if user.id==3:
						signatory = user_views.signatory_info(2)
						status='P'
					else:
						flash('Invalid credentials! Please try again.', 'error')	
						return redirect(url_for('unregistered.event_signing', token=token, action=action))
				elif event.status=='P':
					if user.id==2:
						status='S'
						event_information.update_status(event.id, status)
					else:
						flash('Invalid credentials! Please try again.', 'error')
						return redirect(url_for('unregistered.event_signing', token=token, action=action))	

				proposal_tracker.update_status(event.id, status)

				value = [None,user.id,event.id,'event', 5]
				audit_trail.add(value)

				if status!='S':

					recipient = signatory.email_address
					name = 'Fr. ' + signatory.last_name + ', OAR'
					token = generate(event.id)
					approve = url_for('unregistered.event_signing', token=token , action='approve', _external = True)
					decline = url_for('unregistered.event_signing', token=token , action='decline', _external = True)		
					html = render_template('admin/email/event.html', event=event , organizer=organizer.company_name, user=name, link = [approve, decline])
					subject = "NEW EVENT: " + event.name
					attachments = event_attachment.retrieve_files(id)

					email_parts = [html, subject, user.email_address, recipient, attachments]

					send_email(email_parts)

				else:

					recipient = success.email_address
					html = 'Hey ' + success.username + '! Your event entitled ' + event.name.title() + ' was already approved!'
					subject = "NEW EVENT: " + event.name

					email_parts = [html, subject, user.email_address, recipient, None]

					send_email(email_parts)

				flash(event.name.title() + ' was approved!', 'success')
				return redirect('/')

			else:

				if event.status=='A':
					if user.id!=4:
						flash('Invalid credentials! Please try again.', 'error')	
						return redirect(url_for('unregistered.event_signing', token=token, action=action))
				elif event.status=='F':
					if user.id!=3:
						flash('Invalid credentials! Please try again.', 'error')	
						return redirect(url_for('unregistered.event_signing', token=token, action=action))
				elif event.status=='P':
					if user.id!=2:
						flash('Invalid credentials! Please try again.', 'error')
						return redirect(url_for('unregistered.event_signing', token=token, action=action))

				status='X'
				proposal_tracker.update_status(event.id, status)
				event_information.update_status(event.id, status)

				value = [None,user.id,event.id,'event', 6]
				audit_trail.add(value)

				flash(event.name.title() + ' was declined!', 'success')
				return redirect('/')

		else:

			flash('Invalid credentials! Please try again.', 'error')

	return render_template('/unregistered/events/signing.html', form=form, action=action, event=event)