Skip to content

Commit

Permalink
merged in the latest v0.5.5 release
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkingham committed Feb 26, 2016
2 parents d14e6da + 39a4f4f commit 14251e4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 89 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

### 0.6.0 (Major Release)


Expand All @@ -19,7 +18,7 @@ We now expect 'd/m/y' date formatting by default.

#### Patient lists

Lists are now declarative, and separate from teams. They are implemented as
Lists are now declarative, and separate from teams. They are implemented as
subclasses of opal.core.patient_lists.PatientList.

#### Forms vs. Modals
Expand All @@ -36,6 +35,13 @@ Adds $opal checkout for switching between applications or application versions.

* Update your settings to use the new date formats.


### 0.5.5 (Minor Release)
Changes the way old tags are handled.

Tags are no longer deleted episodes, rather they're marked as archived.


### 0.5.4 (Minor Release)
* Include local storage

Expand Down
69 changes: 3 additions & 66 deletions opal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from django.utils import timezone
from django.conf import settings
import reversion

from django.utils import dateparse
from opal.core import application, exceptions, lookuplists, plugins
from opal import managers
from opal.utils import camelcase_to_underscore
Expand Down Expand Up @@ -536,8 +536,7 @@ def set_tag_names(self, tag_names, user):

if "mine" not in tag_names:
self.tagging_set.filter(user=user).update(archived=True)

if "mine" in tag_names:
else:
my_team = Team.objects.get(name="mine")
tag, created = self.tagging_set.get_or_create(
team=my_team, user=user
Expand Down Expand Up @@ -753,6 +752,7 @@ def get_modal_template(cls, team=None, subteam=None):
if subteam:
templates.insert(0, 'modals/{0}/{1}/{2}_modal.html'.format(
team, subteam, name))

if cls.get_form_template():
templates.append("modal_base.html")

Expand Down Expand Up @@ -911,69 +911,6 @@ def import_from_reversion(cls):

Tagging.objects.bulk_create(tagging_objs)

@classmethod
def historic_tags_for_episodes(cls, episodes):
"""
Given a list of episodes, return a dict indexed by episode id
that contains historic tags for those episodes.
"""
episode_ids = [e.id for e in episodes]
teams = {t.id: t.name for t in Team.objects.all()}
deleted = reversion.get_deleted(cls)
historic = collections.defaultdict(dict)

for d in deleted:
data = json.loads(d.serialized_data)[0]['fields']
if data['episode'] in episode_ids:
if 'team' in data:
if data['team'] in teams:
tag_name = teams[data['team']]
else:
print 'Team has been deleted since it was serialised.'
print 'We ignore these for now.'
continue
else:
try:
tag_name = data['tag_name']
except KeyError:
print json.dumps(data, indent=2)
raise exceptions.FTWLarryError("Can't find the team in this data :(")

historic[data['episode']][tag_name] = True
return historic

@classmethod
def historic_episodes_for_tag(cls, tag):
"""
Given a TAG return a list of episodes that have historically been
tagged with it.
"""
teams = {t.id: t.name for t in Team.objects.all()}
deleted = reversion.get_deleted(cls)
eids = set()

for d in deleted:
data = json.loads(d.serialized_data)[0]['fields']
try:
team_index = data['team']
if team_index not in teams:
print "Can't find deleted team by index - we think the team has been deleted? "
print "DATA:"
print json.dumps(data, indent=2)
print "TEAMS:"
print json.dumps(teams, indent=2)
continue
tag_name = teams[team_index]

except KeyError:
tag_name = data['tag_name']

if tag_name == tag:
eids.add(data['episode'])

historic = Episode.objects.filter(id__in=eids)
return historic


"""
Base Lookup Lists
Expand Down
3 changes: 1 addition & 2 deletions opal/tests/test_episode.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ def test_set_tagging_parent(self):
def test_user_cannot_see_other_users_mine_tag(self):
other_user = User.objects.create(username='seconduser')
self.episode.set_tag_names(['hiv', 'mine'], self.user)
result = list(self.episode.get_tag_names(other_user))
self.assertEqual([u'hiv'], result)
self.assertEqual(['hiv'], list(self.episode.get_tag_names(other_user)))

def test_active_if_tagged_by_non_mine_tag(self):
self.episode.set_tag_names(['microbiology'], self.user)
Expand Down
17 changes: 1 addition & 16 deletions opal/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def test_detail_template_subteam(self, select):
['records/subrecord_detail.html',
'records/subrecord.html'])


@patch('opal.models.select_template')
def test_form_template(self, select):
Subrecord.get_form_template()
Expand All @@ -77,22 +78,6 @@ def test_modal_template_no_form_template(self, modal, select):
Subrecord.get_modal_template()
select.assert_called_with(['modals/subrecord_modal.html'])

@patch('opal.models.select_template')
@patch('opal.models.Subrecord.get_form_template')
def test_modal_template_with_form_template(self, modal, select):
modal.return_value = 'forms/subrecord_form.html'
Subrecord.get_modal_template()
select.assert_called_with(['modals/subrecord_modal.html', 'modal_base.html'])

@patch('opal.models.select_template')
def test_modal_template_team(self, select):
Subrecord.get_modal_template(team='test')
select.assert_called_with([
'modals/test/subrecord_modal.html',
'modals/subrecord_modal.html',
'modal_base.html'
])

@patch('opal.models.select_template')
def test_modal_template_subteam(self, select):
Subrecord.get_modal_template(team='test', subteam='really')
Expand Down
3 changes: 0 additions & 3 deletions opal/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,6 @@ def episode_list_and_create_view(request):
return _build_json_response(serialised, status_code=201)





class EpisodeCopyToCategoryView(LoginRequiredMixin, View):
"""
Copy an episode to a given category, excluding tagging.
Expand Down

0 comments on commit 14251e4

Please sign in to comment.