Re: Django confirm email. Change value from false to true

2012-09-20 Thread Stephen Anto
Hi,

Just fllow bellow steps:

In urls.py add bellow url

urlpatterns = patterns('',
url('^meeting/$',
'meeting', name='meeting'),
url('^meeting/confirm/(\w+)/$','meeting_confirm',
name='meeting_confirm'),
)

In views.py add bellow methods

def meeting(request):
form = MeetingForm()
pDict = request.POST.copy()
if request.method == 'POST':
form = MeetingForm(pDict)
if form.is_valid():
try:
meeting_obj = Meeting()
meeting_obj.name = pDict['name']
meeting_obj.time = pDict['time']
meeting_obj.confirmed = 0
meeting_obj.save()

path = reverse('meeting_confirm'',args=[meeting_obj.id])
activation_url = u"%s%s" % (unicode(settings.CURRENT_SITE),
path)

context = {
"email":pDict['user_email']
"first_name":pDict['user_name'],
"activation_url": activation_url,
}

 emails/user/meeting_subject.txt #
 emails/user/meeting_msg.txt ###
# Above are templates files for email. You should design as
you want

subject =
render_to_string('emails/user/meeting_subject.txt', context)
subject = "".join(subject.splitlines())
message = render_to_string('emails/user/meeting_msg.txt',
context)
msg = EmailMultiAlternatives(subject,message, '
ad...@example.com',pDict['user_email'])
msg.attach_alternative(message, "text/html")
msg.send()

except:
pass

return render_to_response('meeting.html',
locals(),context_instance=RequestContext(request))

def meeting_confirm(request,id):
meeting_obj = Meeting.objects.get(id=id)
meeting_obj.confirmed = 1
meeting_obj.save()

msg = 'Meeting has been confirmed!'

return render_to_response('meeting_confirm.html',
locals(),context_instance=RequestContext(request))

I believe it may help you. For more http://f2finterview.com/web/Django/ Than
you for visiting 
On Wed, Sep 19, 2012 at 1:23 AM, enemybass  wrote:

> This is my model:
>
> from django.db import models
>
> class Meeting(models.Model):
> name = models.CharField(max_length=255)
> time = models.DateTimeField()
> confirmed = models.BooleanField(default=False)
>
> This is my form:
>
> from django import forms
>
> class MeetingForm(forms.Form):
> name = forms.CharField(max_length=100)
> time = forms.DateTimeField()
> user_name = forms.CharField(max_length=100)
> user_email = forms.EmailField()
>
> How to create a view that send a mail to user with link and when user
> clicks on this link confrimed field will change value to true?
>
> Link is my biggest problem.
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/01tWYQEuJ9IJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Thanks & Regards
Stephen S



Website: www.f2finterview.com
Blog:  blog.f2finterview.com
Tutorial:  tutorial.f2finterview.com
Group:www.charvigroups.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django confirm email. Change value from false to true

2012-09-18 Thread enemybass
This is my model:

from django.db import models

class Meeting(models.Model):
name = models.CharField(max_length=255)
time = models.DateTimeField()
confirmed = models.BooleanField(default=False)

This is my form:

from django import forms

class MeetingForm(forms.Form):
name = forms.CharField(max_length=100)
time = forms.DateTimeField()
user_name = forms.CharField(max_length=100)
user_email = forms.EmailField()

How to create a view that send a mail to user with link and when user 
clicks on this link confrimed field will change value to true?

Link is my biggest problem.



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/01tWYQEuJ9IJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.