6 from django.contrib.auth.decorators import login_required |
6 from django.contrib.auth.decorators import login_required |
7 |
7 |
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 |
12 |
12 def show_msg(message, redirect_url=None, url_desc=None): |
13 def show_msg(message, redirect_url=None, url_desc=None): |
13 """ simply redirect to homepage """ |
14 """ simply redirect to homepage """ |
14 |
15 |
15 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}) |
136 def process_request(request, rid, reply): |
139 def process_request(request, rid, reply): |
137 """ check if the method is post and then update the request. |
140 """ check if the method is post and then update the request. |
138 if it is get, display a 404 error. |
141 if it is get, display a 404 error. |
139 """ |
142 """ |
140 |
143 |
|
144 user = request.user |
|
145 |
141 if request.method=="POST": |
146 if request.method=="POST": |
142 user = request.user |
|
143 browse_request_url= '/user/requests' |
147 browse_request_url= '/user/requests' |
144 reqs = user.request_sent_to.filter(is_replied=False).order_by('creation_date') |
148 reqs = user.request_sent_to.filter(is_replied=False).order_by('creation_date') |
145 user_request = reqs[int(rid)] |
149 req_obj = reqs[int(rid)] |
|
150 reply = True if reply == "yes" else False |
|
151 reply_to_request(req_obj, reply, user) |
146 |
152 |
147 return show_msg("Your reply has been processed", browse_request_url, "view other requests") |
153 return show_msg("Your reply has been processed", browse_request_url, "view other requests") |
148 else: |
154 else: |
149 return show_msg("You are not authorised to do this", browse_request_url, "view other requests") |
155 return show_msg("You are not authorised to do this", browse_request_url, "view other requests") |