-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from spellew/work-entity-support
CB-270: Implemented the reviewal of works
- Loading branch information
Showing
25 changed files
with
478 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TYPE entity_types ADD VALUE 'work' AFTER 'recording'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ CREATE TYPE entity_types AS ENUM ( | |
'release_group', | ||
'event', | ||
'place', | ||
'work', | ||
'artist', | ||
'label' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
"event", | ||
"place", | ||
"release_group", | ||
"work", | ||
"artist", | ||
"label", | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from brainzutils import cache | ||
from brainzutils.musicbrainz_db.work import fetch_multiple_works | ||
from critiquebrainz.frontend.external.musicbrainz_db import DEFAULT_CACHE_EXPIRATION | ||
|
||
|
||
def get_work_by_id(mbid): | ||
"""Get work with MusicBrainz ID. | ||
Args: | ||
mbid (uuid): MBID(gid) of the work. | ||
Returns: | ||
Dictionary containing the work information | ||
""" | ||
key = cache.gen_key(mbid) | ||
work = cache.get(key) | ||
if not work: | ||
work = fetch_multiple_works( | ||
[mbid], | ||
includes=['artist-rels', 'recording-rels'], | ||
).get(mbid) | ||
cache.set(key=key, val=work, time=DEFAULT_CACHE_EXPIRATION) | ||
return work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% extends 'review/entity/base.html' %} | ||
|
||
{% set work = review.entity_id | entity_details(type='work') %} | ||
|
||
{% block title %} | ||
{% set work_title = work.name | default(_('[Unknown work]')) %} | ||
{{ _('Review of "%(work)s" by %(user)s', work=work_title, user=review.user.display_name) }} - CritiqueBrainz | ||
{% endblock %} | ||
|
||
{% block entity_title %} | ||
<h2 id="title"> | ||
{% if work %} | ||
{% set work_name = '<a href="%s">' | safe % url_for('work.entity', id=review.entity_id) ~ work.name ~ '</a>'|safe %} | ||
{% else %} | ||
{% set work_name = _('[Unknown work]') %} | ||
{% endif %} | ||
|
||
{{ _('%(work)s', work=work_name) }} | ||
|
||
{% if work['life-span'] %} | ||
<small>{{ work['life-span']['begin'][:4] }}</small> | ||
{% endif %} | ||
</h2> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% if entity is not defined %} | ||
{% set entity = review.entity_id | entity_details(type=entity_type) %} | ||
{% endif %} | ||
<div class="col-md-12"> | ||
<dl class="dl-horizontal"> | ||
<dt>{{ _('Work') }}</dt> | ||
<dd> | ||
{{ entity['name'] | default(_('[Unknown work]')) }} | ||
</dd> | ||
<dt>{{ _('Type') }}</dt> | ||
<dd>{{ entity['type'] or '-' }}</dd> | ||
<dt>{{ _('Artists') }}</dt> | ||
<dd> | ||
{% if entity['artist-rels'] %} | ||
{{ entity['artist-rels'][0]['artist']['name'] or '-' }} | ||
{% set count = entity['artist-rels'] | length %} | ||
{% if count > 1 %} | ||
+ {{ count - 1 }} {{ _("more") }} | ||
{% endif %} | ||
{% else %} | ||
- | ||
{% endif %} | ||
</dd> | ||
{% block more_info %} | ||
{# Information like creation date, votes etc. #} | ||
{% endblock %} | ||
</dl> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.