Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #48

Merged
merged 3 commits into from
Jul 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
14 changes: 14 additions & 0 deletions cwr_webclient/view/mera/match/templates/macro/mera_options.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ <h2 class="panel-title">
<div class="panel-body">
<fieldset>

<h3>General</h3>

<div class="control-group">
<label class="control-label" for="artist.threshold">score
threshold</label>

<div class="controls">
<input id="score.threshold" name="artist.threshold"
type="text" value="0.9"
class="input-xlarge" required="">

</div>
</div>

<h3>Blocking</h3>

<div class="control-group">
Expand Down
1 change: 1 addition & 0 deletions tests/service/test_cwr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def setUp(self):
'http://127.0.0.1:1',
'http://127.0.0.1:1',
'http://127.0.0.1:1',
'http://127.0.0.1:1',
'http://127.0.0.1:1')

def test_process(self):
Expand Down