Beispiel #1
0
def view_contactus(request, contactus_template):
    if request.method == 'GET':
        return response(request, contactus_template, {'form':ContactUsForm()})
    form = ContactUsForm(post_data(request))
    if form.is_valid():
        mail_admins(from_email=form.cleaned_data.get('from_email'),
                    from_name=form.cleaned_data.get('from_name'),
                    subject=form.cleaned_data.get('subject'),
                    message=form.cleaned_data.get('message'))
        from users.messages import CONTACTED_SUCCESSFULLY
        messages.success(request, CONTACTED_SUCCESSFULLY)
        return HttpResponseRedirect(redirect_to='/')
    return response(request, contactus_template, {'form':form})
Beispiel #2
0
 def execute(self):
     try:
         import time
         start = time.time()
         from utils import load_module
         method = load_module(self.action)
         argument = self._args()
         result = method(self.owner,argument)
         self.done()
         end = time.time()
         print 'Executing the job with jobid:%s took:%s seconds' % (self.id,(end-start))
         return result
     except Exception,e:
         message= self.action +'\n'
         message+='Exception raised while executing Job with jobid:%s :%s' % (self.id,e.__str__()+'\n')
         print message
         from utils.emailer import mail_admins
         mail_admins(message,locals())
Beispiel #3
0
def view_makeorder(request):
    try:
        response_dict = {}
        totalbill = _request_param_post(request,'totalbill')
        ordered_items = _clean_ordered_items_ids_quantity(_request_param_post(request,'ordered_items_ids_quantity'))
        deliverytime = _clean_time(_request_param_post(request,'deliverytime'))
        userprofile = request.user.get_profile()
        from users.models import UserOrder
        order = UserOrder.objects.create_userorder(userprofile=userprofile, deliverytime=deliverytime, menuitems=ordered_items, totalcost=totalbill)
        response_dict['id'] = order.id
        response_dict['code'] = order.code
        response_dict['status'] = '200'
    except Exception,e:
        from utils.emailer import mail_admins
        mail_admins(e,locals())
        print 'Exception:%s' % e.__str__()
        response_dict['id'] = None
        response_dict['code'] = None
        response_dict['status'] = '500'