Skip to content

Commit

Permalink
Added support for match feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardo-MG committed Jul 20, 2015
1 parent a6ef29d commit 2903e5d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cwr_webclient/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ def _load_services(app, config):
match_begin = admin_ws + 'match/begin/'
match_reject = admin_ws + 'match/reject/'
match_accept = admin_ws + 'match/confirm/'
match_feedback = admin_ws + 'match/feedback/'

service_admin = WSCWRService(process_cwr,
files,
remove_cwr,
match_begin,
match_reject,
match_accept)
match_accept,
match_feedback)

app.config['CWR_ADMIN_SERVICE'] = service_admin
app.config['PAGINATION_SERVICE'] = DefaultPaginationService(
Expand Down
17 changes: 16 additions & 1 deletion cwr_webclient/service/cwr_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ def get_file(self, file_id):

class WSCWRService(CWRService):
def __init__(self, url, url_files, url_file_delete, url_match_begin,
url_match_reject, url_match_confirm):
url_match_reject, url_match_confirm, url_match_feedback):
super(WSCWRService, self).__init__()
self._url = url
self._url_files = url_files
self._url_file_delete = url_file_delete
self._url_match_begin = url_match_begin
self._url_match_reject = url_match_reject
self._url_match_confirm = url_match_confirm
self._url_match_feedback = url_match_feedback

def process(self, file_data):
data = {}
Expand Down Expand Up @@ -79,6 +80,20 @@ def begin_match(self, file_id, config):
except (ConnectionError, ValueError):
_logger.info('Error asking for match')

def send_feedback(self, file_id):
headers = {'Accept': 'application/json',
'Content-Type': 'application/json'}

data = {}
data['file_id'] = file_id

data = json.dumps(data)

try:
requests.post(self._url_match_feedback, data=data, headers=headers)
except (ConnectionError, ValueError):
_logger.info('Error sending feedback')

def reject_match(self, file_id, pos):
headers = {'Accept': 'application/json',
'Content-Type': 'application/json'}
Expand Down
8 changes: 8 additions & 0 deletions cwr_webclient/view/cwr/file/templates/cwr_file_listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ <h3 class="panel-title">Users</h3>
</th>
<th>Contents</th>
<th>Matching</th>
<th>Feedback</th>
<th>Delete</th>
</tr>
</thead>
Expand Down Expand Up @@ -81,6 +82,13 @@ <h3 class="panel-title">Users</h3>
{% endif %}
{% endif %}
{% endif %}
{% if file.match_status == 'done' %}
<td>
<a href="{{ url_for('mera_match.feedback', file_id=file.file_id) }}">Send</a>
</td>
{% else %}
<td>Needs match</td>
{% endif %}
<td>
<a href="{{ url_for('cwr_file.delete', file_id=file.file_id) }}"
onclick='return confirm("Are you sure you want to delete the file {{file.name}}?")'><span
Expand Down
11 changes: 11 additions & 0 deletions cwr_webclient/view/mera/match/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ def begin(file_id):
return render_template('mera_match_send.html', file_id=file_id)


@mera_match_blueprint.route('/feedback/<string:file_id>', methods=['GET'])
def feedback(file_id):
_logger.info('Sending feedback for id %s' % file_id)

match_service = current_app.config['CWR_ADMIN_SERVICE']

match_service.send_feedback(file_id)

return redirect(url_for('cwr_file.list'))


@mera_match_blueprint.route('/reject/<string:file_id><int:pos>',
methods=['GET'])
def reject_match(file_id, pos):
Expand Down

0 comments on commit 2903e5d

Please sign in to comment.