Esempio n. 1
0
 def decorator(request, *args, **kwargs):
     event = get_event_by_id(kwargs["event_id"])
     user = get_user_profile(request.user.id)
     if user.is_ambassador():
         return func(request, *args, **kwargs)
     else:
         return HttpResponseRedirect(reverse("web.index"))
Esempio n. 2
0
def edit_profile(request, user_id):

	profile = get_user_profile(user_id)

	if profile:
		user_data = profile.__dict__
		user_data.update(profile.user.__dict__)
		form = UserProfileForm(initial=user_data)
	else:
		user = get_user(user_id)
		form = UserProfileForm(initial=user.__dict__)

	if request.method == 'POST':
		form = UserProfileForm(request.POST, request.FILES)
	if form.is_valid():

		user_data = {}
		user_data.update(form.cleaned_data)

		if request.FILES.get('avatar'):
			user_data['avatar'] = request.FILES['avatar']
		else:
			del user_data['avatar']

		create_or_update_profile(user_id, **user_data)
		return HttpResponseRedirect(reverse('profile', args=[user_id]))

	return render_to_response('user/profile_edit.html', {
		'form': form,
	    'profile': profile,
	}, context_instance=RequestContext(request))
Esempio n. 3
0
def edit_profile(request, user_id):
	current_user = request.user.id
	if current_user == int(user_id):
		profile = get_user_profile(user_id)
		if profile:
			form = UserProfileForm(initial=profile.__dict__)
		else:
			form = UserProfileForm()

		if request.method == 'POST':
			form = UserProfileForm(request.POST, request.FILES)
		if form.is_valid():
			# user profile create or update
			user_data = {}
			user_data.update(form.cleaned_data)

			profile = create_or_update_profile(user_id, **user_data)
			return HttpResponseRedirect(reverse('profile', args=[user_id]))

		return render_to_response('registration/user_profile.html', {
				'form': form,
			    'profile': profile,
			}, context_instance=RequestContext(request))
	else:
		return HttpResponseRedirect("/")
Esempio n. 4
0
 def decorator(request, *args, **kwargs):
     event = get_event_by_id(kwargs['event_id'])
     user = get_user_profile(request.user.id)
     if user.is_ambassador():
         return func(request, *args, **kwargs)
     else:
         return HttpResponseRedirect(reverse('web.index'))
Esempio n. 5
0
def profile(request, user_id):
	user = get_user(user_id)
	all_actions = Action.objects.filter(organizer=user)
	user_profile = get_user_profile(user_id)
	return render_to_response(
		'user/profile.html', {
		'user': user,
		'user_profile': user_profile,
		'actions': all_actions,
		},
		context_instance=RequestContext(request))
Esempio n. 6
0
	def decorator(request, *args, **kwargs):
		user = get_user_profile(request.user.id)
		if user.is_ambassador():
			return func(request, *args, **kwargs)
		else:
			return HttpResponseRedirect(reverse('web.index'))