Esempio n. 1
0
def _process_restfood_account_information(userprofile,request,account_template):
    password = _request_param_post(request, 'password')
    mobile = _request_param_post(request, 'mobile')
    office_place = _request_param_post(request, 'office_place')
    office_landmark = _request_param_post(request, 'office_landmark')
    office_area = _request_param_post(request, 'office_area')
    office_zip = _request_param_post(request, 'office_zip')
    from users.forms import AccountForm
    accountform = AccountForm({'mobile':mobile,'password':password,
                               'home_place':userprofile.source.place,'home_landmark':userprofile.source.landmark,'home_area':userprofile.source.area,'home_zip':userprofile.source.zip,
                               'office_place':office_place,'office_landmark':office_landmark,'office_area':office_area,'office_zip':office_zip})
    if not accountform.is_valid():
        _add_errormsg(request, 'Please valid information in all the required fields')
        return response(account_template,locals(),request)
    password = accountform.cleaned_data.get('password')
    print 'password:%s' % password
    userprofile.set_password(password)
    print 'password reset done'
    mobile = accountform.cleaned_data.get('mobile')
    userprofile.mobile = mobile
    userprofile.save()
    office_place = accountform.cleaned_data.get('office_place')
    office_landmark = accountform.cleaned_data.get('office_landmark')
    office_area = accountform.cleaned_data.get('office_area')
    office_zip = accountform.cleaned_data.get('office_zip')
    userprofile.set_destination_address(destination_place=office_place,destination_area=office_area,destination_landmark=office_landmark,destination_zip=office_zip)
    _add_successmsg(request, 'Account Information saved Successfully')
    return response(account_template,locals(),request)
Esempio n. 2
0
def _send_invitations(request,name, email, ref_emails, ref_mobiles):
    datalist = []
    referfriend_mail_sub = "Do you know about Favmeal?"
    all_emails_list = ref_emails.strip().split(',')
    try:
        from django.core.mail import send_mail, EmailMessage
        from django.template.loader import render_to_string
        html_content = render_to_string('referfriend_mail_content.html', {name:name})
        
        if name:
            from_email = '%s<%s>' % (name, email)
        else:
            from_email = '%s<%s>' % (email, email)
        for to_email in all_emails_list:
            msg = EmailMessage(referfriend_mail_sub, html_content, from_email, [to_email])
            msg.content_subtype = "html"
            msg.attach_file(settings.MEDIA_ROOT+'flat/Favmeal_Brochure.pdf')
            all_invited = msg.send(fail_silently=False)
        #FIXME:Refactor the below code
        admin_mail_sub = "[Refer Friend] By %s<%s>" % (name,email)
        admin_mail_body = "From: %s<%s>\nReferred email Ids: %s; Referred Mobiles: %s" % (name,email,ref_emails,ref_mobiles)
        admin_mail_sent = send_mail(admin_mail_sub, admin_mail_body, '',['*****@*****.**'], fail_silently=False)
    except Exception,e:
        #FIXME:Avoid global Exceptions. Have proper handling mechanism for each case
        _add_errormsg(request,'We are facing difficulty with mail servers. Please try again.')
        return False
Esempio n. 3
0
def view_contactus(request,homepage_template,contactus_template):
    selected_maintab = 'contactus'
    if request.method != 'POST':
        from common.forms import ContactUsQueryForm
        form = ContactUsQueryForm()
        return response(contactus_template, locals(), request)
    from common.forms import ContactUsQueryForm
    form = ContactUsQueryForm(post_data(request))
    if not form.is_valid():
        return response(contactus_template, locals(), request)
    email = form.cleaned_data.get('email')
    name = form.cleaned_data.get('name')
    query = form.cleaned_data.get('query')
    from utils.emailer import customer_query_emailer
    mail_sent = customer_query_emailer(subject="Customer Query",from_email=email,email_body=query,from_name=name)
    if mail_sent:
        _add_successmsg(request,'Query Successfully Submitted. We will get back to you very soon. Thankyou.')
        return response(homepage_template, locals(), request)
    _add_errormsg(request,'Query can\'t be submitted now. Please try again.')
    return response(contactus_template, locals(), request)
Esempio n. 4
0
def view_refer_friend(request, referfriend_template):
    if request.method != 'POST':
        from common.forms import ReferFriendForm
        form = ReferFriendForm()
        return response(referfriend_template, locals(), request)
    from common.forms import ReferFriendForm
    form = ReferFriendForm(post_data(request))
    if not form.is_valid():
        _add_errormsg(request,'Please fill up valid inforsettingsmation in required fields')
        return response(referfriend_template, locals(), request)
    name = form.cleaned_data.get('name')
    email = form.cleaned_data.get('email')
    ref_emails = form.cleaned_data.get('ref_emails')
    ref_mobiles = form.cleaned_data.get('ref_mobiles')
    if _send_invitations(request,name, email, ref_emails, ref_mobiles):
        _add_successmsg(request, 'Your friend(s) \' %s \' have been invited. Thanks for being with favmeal!' % (ref_emails))
        return response(referfriend_template, locals(), request)        
    else:
        _add_errormsg(request,'There seems to be a problem in sending the invitation. Please try again!')
        return response(referfriend_template, locals(), request)        
Esempio n. 5
0
def view_login(request, login_template):
    selected_maintab = 'login'
    if request.method != 'POST':
        from users.forms import LoginForm
        loginform = LoginForm()
        return response(login_template,locals(),request)
    from users.forms import LoginForm
    loginform = LoginForm(post_data(request))
    if loginform.is_valid():
        email = loginform.cleaned_data.get('lusername')
        password = loginform.cleaned_data.get('lpassword')
        from utils import setup_loggedin_environment
        user = setup_loggedin_environment(request, email, password)
        if not user:
            from users.messages import INVALID_LOGIN_INFO
            _add_errormsg(request, INVALID_LOGIN_INFO)
            return response(login_template,locals(),request)
        from utils import get_post_login_url
        post_login_url = get_post_login_url(user.get_profile())
        return HttpResponseRedirect(post_login_url)
    return response(login_template,locals(),request)
Esempio n. 6
0
def _process_homefood_account_information(userprofile,request,account_template):
    from users.forms import AccountForm
    accountform = AccountForm(post_data(request))
    if not accountform.is_valid():
        _add_errormsg(request, 'Please valid information in all the required fields')
        return response(account_template,locals(),request)
    password = accountform.cleaned_data.get('password')
    userprofile.set_password(password)
    mobile = accountform.cleaned_data.get('mobile')
    userprofile.mobile = mobile
    home_place = accountform.cleaned_data.get('home_place')
    home_landmark = accountform.cleaned_data.get('home_landmark')
    home_area = accountform.cleaned_data.get('home_area')
    home_zip = accountform.cleaned_data.get('home_zip')
    userprofile.set_source_address(source_place=home_place,source_area=home_area,source_landmark=home_landmark,source_zip=home_zip)
    office_place = accountform.cleaned_data.get('office_place')
    office_landmark = accountform.cleaned_data.get('office_landmark')
    office_area = accountform.cleaned_data.get('office_area')
    office_zip = accountform.cleaned_data.get('office_zip')
    userprofile.set_destination_address(destination_place=office_place,destination_area=office_area,destination_landmark=office_landmark,destination_zip=office_zip)
    _add_successmsg(request, 'Account Information saved Successfully')
    return response(account_template,locals(),request)