taskapp/views/user.py
changeset 108 131554cc3434
parent 104 d1bdd5d6c1a6
child 111 c272d4c601cd
equal deleted inserted replaced
107:4903b4973fc8 108:131554cc3434
     8 from pytask.taskapp.models import Task, Profile, Request
     8 from pytask.taskapp.models import Task, Profile, Request
     9 from pytask.taskapp.events.user import createUser, updateProfile
     9 from pytask.taskapp.events.user import createUser, updateProfile
    10 from pytask.taskapp.forms.user import UserProfileEditForm
    10 from pytask.taskapp.forms.user import UserProfileEditForm
    11 from pytask.taskapp.events.request import reply_to_request
    11 from pytask.taskapp.events.request import reply_to_request
    12 
    12 
    13 def show_msg(message, redirect_url=None, url_desc=None):
    13 def show_msg(user, message, redirect_url=None, url_desc=None):
    14     """ simply redirect to homepage """
    14     """ simply redirect to homepage """
    15     
    15     
    16     return render_to_response('show_msg.html',{'message':message, 'redirect_url':redirect_url, 'url_desc':url_desc})
    16     return render_to_response('show_msg.html',{'message':message, 'redirect_url':redirect_url, 'url_desc':url_desc})
    17 
    17 
    18 def homepage(request):
    18 def homepage(request):
   151         req_obj.remarks = request.POST.get('remarks', "")
   151         req_obj.remarks = request.POST.get('remarks', "")
   152         req_obj.save()
   152         req_obj.save()
   153 
   153 
   154         reply_to_request(req_obj, reply, user)
   154         reply_to_request(req_obj, reply, user)
   155         
   155         
   156         return show_msg("Your reply has been processed", browse_request_url, "view other requests")
   156         return show_msg(user, "Your reply has been processed", browse_request_url, "view other requests")
   157     else:
   157     else:
   158         return show_msg("You are not authorised to do this", browse_request_url, "view other requests")
   158         return show_msg(user, "You are not authorised to do this", browse_request_url, "view other requests")
   159 
   159 
   160 @login_required
   160 @login_required
   161 def browse_notifications(request):
   161 def browse_notifications(request):
   162     """ get the list of notifications that are not deleted and display in datetime order.
   162     """ get the list of notifications that are not deleted and display in datetime order.
   163     """
   163     """
   213             notification.is_read = False
   213             notification.is_read = False
   214         
   214         
   215         notification.save()
   215         notification.save()
   216         return redirect(notifications_url)
   216         return redirect(notifications_url)
   217     else:
   217     else:
   218         return show_msg('This is wrong', notification_url, "view the notification")
   218         return show_msg(user, 'This is wrong', notification_url, "view the notification")
   219    
   219