Beispiel #1
0
 def save(self, user, event):
     try:
         rsvp = RSVP.objects.get(event=event,user=user) 
         if rsvp.attending != self.cleaned_data['attend']:
             rsvp.attending = self.cleaned_data['attend']
             rsvp.save()
     except RSVP.DoesNotExist:
         rsvp = RSVP(event=event, user=user,
                 attending=self.cleaned_data['attend'])
         rsvp.save()
     return rsvp
Beispiel #2
0
 def save(self, user, event):
     try:
         rsvp = RSVP.objects.get(event=event, user=user)
         if rsvp.attending != self.cleaned_data['attend']:
             rsvp.attending = self.cleaned_data['attend']
             rsvp.save()
     except RSVP.DoesNotExist:
         rsvp = RSVP(event=event,
                     user=user,
                     attending=self.cleaned_data['attend'])
         rsvp.save()
     return rsvp
Beispiel #3
0
def reserve(request):
	context = RequestContext(request)
	try:
		if request.method == 'POST':
			guest_id = request.POST['id']
			event_id = request.POST['event']
			reservation = RSVP(
				event_id = event_id,
				guest_id = guest_id,
				response = 'A'
				)
			reservation.save()
			return HttpResponse('You have successfully reserved for this event')
	except:
		print sys.exc_info()[0], sys.exc_info()[1]
		return HttpResponse('There was an error processing your request')
Beispiel #4
0
def serialise_events_for_query(
    query, user=None, facebook=False, provide_favourite_state=False, provide_rsvp_state=False
):
    """ only shows active events!
    """

    contents = ""

    query.filter("active =", True)
    query.filter("moderated =", True)

    for e in query:
        if e.name and e.location and e.type:
            if facebook is True:
                absolute_url = e.get_facebook_url()
            else:
                absolute_url = e.get_absolute_url()

            contents_list = [
                "[" + e.country.key().name() + "] " + prepare_for_csv(e.name),
                e.type,
                # numeric value out of type string
                str(e.fields()["type"].make_value_from_form(e.type)),
                # sorting needs nice arranged format...
                e.date_start.strftime("%Y-%m-%d (%a) at %H:%M%Z"),
                e.date_end.strftime("%Y-%m-%d (%a) at %H:%M%Z"),
                # e.date_end.strftime('%a %d %b %Y at %H:%M%Z'),
                # e.date_end.isoformat(' '),
                e.recurrent,
                e.location.__str__(),
                absolute_url,
                str(e.key().id()),
                str(e.featured_priority),
                str(int(e.free)),
            ]

            if provide_favourite_state:
                if user and user.is_authenticated():
                    is_fav = Favourite.all().filter("event =", e).filter("user ="******"event =", e).filter("user ="******",")
            contents += "\n"

    return contents
Beispiel #5
0
def new_rsvp(event_id):
    if session.get('user'):
        rsvp_form = RSVPForm()
        # validate_on_submit only validates using POST
        if rsvp_form.validate_on_submit():
            new_rsvp = RSVP(event_id, session['user_id'])
            db.session.add(new_rsvp)
            db.session.commit()

        return redirect(url_for('get_event', event_id=event_id))

    else:
        return redirect(url_for('login'))
Beispiel #6
0
def rsvp_for_meal(MealId):
    try:
        rsvp = RSVP(MealId=MealId,
                    Email=current_user.Email,
                    Timestamp=datetime.datetime.now())

        # Check if user already is RSVP'd
        if session.query(RSVP).filter(RSVP.MealId == rsvp.MealId, RSVP.Email
                                      == rsvp.Email).first() is None:
            session.add(rsvp)
            session.commit()
            flash("Success! You RSVP'd.")
        else:
            flash("You were already RSVP'd for that meal.")

        return redirect(url_for("get_meal", mealId=MealId))
    except Exception as e:
        print(
            "RSVP for Meal with ID of {} was unsuccessful. Please try again. {}"
            .format(MealId, e))
        return redirect(url_for("get_meal", mealId=MealId))
Beispiel #7
0
def create_rsvp(user, occurrence):
	if user in occurrence.users.all():
		return

	rsvp = RSVP(user=user, occurrence=occurrence)
	rsvp.save()