Skip to content

Commit

Permalink
Picking up where we left ...
Browse files Browse the repository at this point in the history
  • Loading branch information
elbenfreund committed Nov 17, 2017
1 parent 82fad51 commit 3fe166f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
18 changes: 15 additions & 3 deletions hamster_gtk/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def decompose_raw_fact_string(text, raw=False):


# [TODO]
# Oncec LIB-251 has been fixed this should no longer be needed.
# Once LIB-251 has been fixed this should no longer be needed.
def get_recent_activities(controller, start, end):
"""Return a list of all activities logged in facts within the given timeframe."""
# [FIXME]
Expand All @@ -196,10 +196,22 @@ def get_recent_activities(controller, start, end):
return OrderedSet(recent_activities)


def serialize_activity(activity):
def serialize_activity(activity, seperator='@', none_category='not categorized'):
"""Provide a serialized string version of an activity."""

if not seperator:
raise ValueError(_("No valid separator has been provided."))
if not none_category and none_category is not '':
raise ValueError(_("No valid text for 'none_category' has been provided."))

if activity.category:
result = '{a.name}@{a.category.name}'.format(a=activity)
category_text = activity.category.name
else:
category_text = none_category

if category_text:
result = '{activity_text}{seperator}{category_text}'.format(activity_text=activity.name,
category_text=category_text, seperator=seperator)
else:
result = activity.name
return text_type(result)
Expand Down
14 changes: 6 additions & 8 deletions hamster_gtk/overview/widgets/fact_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,14 @@ def _get_activity_widget(self, fact):
"""Return widget to render the activity, including its related category."""
# [FIXME]
# Once 'preferences/config' is live, we can change this.
# Most likly we do not actually need to jump through extra hoops as
# Most likely we do not actually need to jump through extra hoops as
# legacy hamster did but just use a i18n'ed string and be done.
if not fact.category:
category = 'not categorised'
else:
category = str(fact.category)
activity_label = Gtk.Label()
activity_label.set_markup("{activity} - {category}".format(
activity=GObject.markup_escape_text(fact.activity.name),
category=GObject.markup_escape_text(category)))
#activity_label.set_markup("{activity} - {category}".format(
# activity=GObject.markup_escape_text(fact.activity.name),
# category=GObject.markup_escape_text(category)))
from hamster_gtk import helpers
activity_label.set_markup(GObject.markup_escape_text(helpers.serialize_activity(fact.activity)))
activity_label.props.halign = Gtk.Align.START
return activity_label

Expand Down
6 changes: 3 additions & 3 deletions tests/preferences/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def tracking_show_recent_activities_parametrized(request):


@pytest.fixture(params=(0, 1, 5, 15))
def tracking_recent_activities_items_parametrized(request):
def tracking_recent_activities_count_parametrized(request):
"""Return a parametrized tracking_recent_activities_items_parametrized value."""
return request.param

Expand All @@ -97,7 +97,7 @@ def config_parametrized(request, store_parametrized, day_start_parametrized,
fact_min_delta_parametrized, tmpfile_path_parametrized, db_engine_parametrized,
db_path_parametrized, autocomplete_activities_range_parametrized,
autocomplete_split_activity_parametrized, tracking_show_recent_activities_parametrized,
tracking_recent_activities_items_parametrized):
tracking_recent_activities_count_parametrized):
"""Return a config fixture with heavily parametrized config values."""
return {
'store': store_parametrized,
Expand All @@ -109,7 +109,7 @@ def config_parametrized(request, store_parametrized, day_start_parametrized,
'autocomplete_activities_range': autocomplete_activities_range_parametrized,
'autocomplete_split_activity': autocomplete_split_activity_parametrized,
'tracking_show_recent_activities': tracking_show_recent_activities_parametrized,
'tracking_recent_activities_items': tracking_recent_activities_items_parametrized,
'tracking_recent_activities_count': tracking_recent_activities_count_parametrized,
}


Expand Down

0 comments on commit 3fe166f

Please sign in to comment.