#458 implement hubs widget as per the mockup
Merged by abompard. Opened by ryanlerch.
ryanlerch/fedora-hubs my-hubs  into  develop

Download 458.patch

implement my hubs widget as per the mockup

a rework of the hubs widget to match the mockup, including a
rename from "subscriptions" to "my_hubs"

fixes #436

Thanks! Do you think some unit tests on the view function would be useful? Maybe a couple to make sure nothing gets mixed up between the different hub types and association types?

Okies, added a test to test it out, also fixed a couple of other tests that were failing (i still had subscriptions in the default widget list, rather than the renamed my_hubs) -- whoops!

2 new commits added

  • implement my hubs widget as per the mockup
  • Rename Subscriptions widget to 'My Hubs'

2 new commits added

  • implement my hubs widget as per the mockup
  • Rename Subscriptions widget to 'My Hubs'

rebased onto 536605ef5ee35419f90df8ed333f0cc35a0d6fb9

Leftover print statement! :-)

When I run it on python3 I get the following traceback:

[...]
  File "/home/abompard/Fedora/hubs/fedora-hubs/hubs/widgets/my_hubs/__init__.py", line 64, in execute
    monograms[hub.name] = generate_monogram(hub.name)
  File "/home/abompard/Fedora/hubs/fedora-hubs/hubs/widgets/my_hubs/__init__.py", line 45, in generate_monogram
    colour_index = int(hashlib.md5(hubname).hexdigest(), 16) % 5
TypeError: Unicode-objects must be encoded before hashing

Please encode the hubname to utf-8 before passing it to md5().

Also, do we want to have the username as a config value, or should we just use the hub name? It seems strange to want to display someone else's memberships on one's hub.

Okies, removed the debug print statement i left in there.

Also now encoding the hubname before hashing it so it works on python3.

Also, there was a failing test after rebasing the wigdgets only on certain hub types PR, due to renaming this hub from suscriptions to my_hubs, so i fixed that one too. I squashed these into the main commit here, will do the config value change in a seperate commit.

2 new commits added

  • implement my hubs widget as per the mockup
  • Rename Subscriptions widget to 'My Hubs'

1 new commit added

  • remove username config value from my_hubs widget

okies, added the extra commit that removes the username config item, and just uses the hubname.

rebased onto 2de99eca3ddee4bb306c0c0bb788f9d388a803be

I get these errors when running tox -e lint:

./hubs/widgets/my_hubs/__init__.py:8:1: F401 'hubs.widgets.validators' imported but unused
from hubs.widgets import validators
^
./hubs/widgets/my_hubs/__init__.py:48:35: W291 trailing whitespace
        # hub.name == the username 
                                  ^
./hubs/widgets/my_hubs/__init__.py:53:9: E741 ambiguous variable name 'l'
        l = []
        ^

Also, there's a small conflict in a test due to a recent commit, please rebase.

rebased onto fea8c58766f690937c4dcb74ab43635c7cf36b1a

3 new commits added

  • remove username config value from my_hubs widget
  • implement my hubs widget as per the mockup
  • Rename Subscriptions widget to 'My Hubs'

2 new commits added

  • implement my hubs widget as per the mockup
  • Rename Subscriptions widget to 'My Hubs'

2 new commits added

  • implement my hubs widget as per the mockup
  • Rename Subscriptions widget to 'My Hubs'

@abompard rebased, and fixed the lint issues!

Thanks, it all looks good except it does not update when I join a hub. The invalidation method is waiting for a "hubs.associate" message that is never sent. We have two options:

  • have Hubs send that message, but since Hubs does not currently send any fedmsgs, I'm afraid this might mean some in-depth work to teach it to do that.
  • get rid of the cached function and do it all in the view.

Since all the cached function does is to do SQL queries, I'd be in favor of option 2 at least for the MVP. We will very probably need to teach Hubs to send fedmsgs in the future though.

if we do it all in the view, it still wont update async, right?

FWIW, that invalidation stuff was there to begin with too -- i thought it was not working because it was not hooked up to fedmsg proper.

Yeah there's a lot of not working stuff that was there to begin with ;-)
If we do it in the view the SQL queries will be done on each widget display. It's not ideal from a performance point of view, of course, but every widgets are displayed async anyway so it won't slow down the loading of the page.

okies! removed the caching stuff from this one, and updated the commit.

rebased onto d788a5477c3e24be0d04f556143ca2f38554608e

Pull-Request has been merged by abompard

Thanks! :thumbsup:

Metadata