Ejemplo n.º 1
0
def event_action(id, action):

	event = event_views.show_info(id)
	status = event_participation.show_status([id, current_user.info_id])

	if action == 'join':

		if status:

			value = [event.id, current_user.info_id, 'J']

			event_participation.update(value)

			flash('Successfully	 joined '+event.name, 'success')

		else:

			value = [None, id, current_user.info_id, 'N']

			event_participation.add(value)

			flash('Successfully	 joined '+event.name, 'success')

	else:

		value = [event.id, current_user.info_id, 'C']

		event_participation.update(value)

		flash('Participation has been cancelled!', 'success')

	return redirect(url_for('registered.events', status='all', page='1', search=' '))
Ejemplo n.º 2
0
def event_evaluation(id, search):

    event = event_views.show_info(id)
    participants = event_views.show_attended([id, search])

    form = SearchForm()
    evaluate = EvaluationForm()

    if form.validate_on_submit():

        return redirect(
            url_for('linkages.event_evaluation',
                    id=id,
                    search=form.search.data))

    if evaluate.validate_on_submit():

        print(evaluate.participant.data)
        event_participation.evaluate([
            event.id, evaluate.participant.data, evaluate.rating.data,
            evaluate.comment.data
        ])

        flash('Rating successfully submitted!', 'success')
        return redirect(
            url_for('linkages.event_evaluation', id=id, search=search))

    return render_template('/linkages/events/evaluation.html',
                           title=event.name.title(),
                           event=event,
                           participants=participants,
                           form=form,
                           evaluate=evaluate,
                           search=search,
                           active='events')
Ejemplo n.º 3
0
def event_conduct(id):

    event = event_views.show_info(id)

    return render_template('/linkages/events/conduct.html',
                           title=event.name.title(),
                           event=event,
                           active='events')
Ejemplo n.º 4
0
def event_show(id):

    event = event_views.show_info(id)
    participants = event_views.show_participants([id, ' '])

    form = SearchForm()

    return render_template('/linkages/events/show.html',
                           title=event.name.title(),
                           event=event,
                           participants=participants,
                           form=form,
                           active='events')
Ejemplo n.º 5
0
def event_letter(id, name):

    filepath = 'static/output/events/letters/'

    event = event_views.show_info(id)
    admin = user_information.retrieve_user(1)

    html = render_template('linkages/pdf/pdf.html',
                           event=event,
                           admin=admin,
                           date=datetime.now())

    generate_pdf(html, filepath + str(id) + '.pdf')

    return send_from_directory(filepath, str(id) + '.pdf')
Ejemplo n.º 6
0
def event_participants(id):

    event = event_views.show_info(id)
    participants = community_views.event_participants(id)
    joined = event_participation.show_joined(id)

    form = SearchForm()

    return render_template('/communities/events/add_participants.html',
                           title=event.name.title(),
                           event=event,
                           participants=participants,
                           joined=joined,
                           form=form,
                           active='events')
Ejemplo n.º 7
0
def add_photos(id):

    event = event_views.show_info(id)
    form = PhotoForm()

    print()
    if form.validate_on_submit():

        for file in form.photos.data:

            old, extension = os.path.splitext(file.filename)

            extension = extension.lower()

            if extension == ".jpg" or extension == ".jpeg" or extension == ".png" or extension == ".gif":
                continue
            else:
                flash('Invalid file detected!', 'error')
                return redirect(url_for('linkages.add_photos', id=id))

        path = 'static/photos/events/' + id

        if not os.path.isdir(path):
            os.mkdir(path)

        for file in form.photos.data:

            old, extension = os.path.splitext(file.filename)
            filepath = path + '/' + file.filename
            file.save(filepath)

            value = [None, id, filepath, None, 'Y']
            event_photo.add(value)

        flash('Photos successfully uploaded!', 'success')
        return redirect(url_for('linkages.event_photos', id=id))

    return render_template('/linkages/events/add_photos.html',
                           title=event.name.title(),
                           event=event,
                           form=form,
                           active='events')
Ejemplo n.º 8
0
def event_attendance(id, search):

    event = event_views.show_info(id)
    participants = event_views.show_participants([id, search])

    form = SearchForm()

    if form.validate_on_submit():

        return redirect(
            url_for('linkages.event_attendance',
                    id=id,
                    search=form.search.data))

    return render_template('/linkages/events/attendance.html',
                           title=event.name.title(),
                           event=event,
                           participants=participants,
                           form=form,
                           search=search,
                           active='events')
Ejemplo n.º 9
0
def event_photos(id):

    event = event_views.show_info(id)

    photos = event_photo.show(id)

    form = CaptionForm()

    if form.validate_on_submit():

        value = [form.photo.data, form.caption.data]
        event_photo.caption(value)
        flash('Caption added to photo!', 'success')
        return redirect(url_for('linkages.event_photos', id=event.id))

    return render_template('/linkages/events/photos.html',
                           title=event.name.title(),
                           event=event,
                           photos=photos,
                           form=form,
                           active='events')
Ejemplo n.º 10
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)