Skip to content

Add fake avatars#334

Merged
mrcasals merged 3 commits intomasterfrom
add_fake_avatars
Dec 13, 2016
Merged

Add fake avatars#334
mrcasals merged 3 commits intomasterfrom
add_fake_avatars

Conversation

@mrcasals
Copy link
Copy Markdown
Contributor

@mrcasals mrcasals commented Dec 12, 2016

🎩 What? Why?

This PR adds avatars to users, and sets a default avatar to:

📌 Related Issues

There's no issue for this, but a discussion for this arose in #250. I needed this too in #309.

📋 Subtasks

  • Add code
  • Add tests

📷 Screenshots (optional)

None

@mention-bot
Copy link
Copy Markdown

@mrcasals, thanks for your PR! By analyzing the history of the files in this pull request, we identified @oriolgual, @josepjaume and @beagleknight to be potential reviewers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Freezing immutable objects is pointless.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Freezing immutable objects is pointless.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant curly braces around a hash parameter.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Freeze mutable objects assigned to constants.
Use %w or %W for an array of words.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at class body beginning.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the parameters of a method call if they span more than one line.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing frozen string literal comment.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@mrcasals mrcasals force-pushed the add_fake_avatars branch 2 times, most recently from 0983ca7 to ed14883 Compare December 12, 2016 14:50
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing array brace must be on the same line as the last array element when opening brace is on the same line as the first array element.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the elements of an array literal if they span more than one line.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the elements of an array literal if they span more than one line.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the elements of an array literal if they span more than one line.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the elements of an array literal if they span more than one line.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Within %w/%W, quotes and ',' are unnecessary and may be unwanted in the resulting strings.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the parameters of a method call if they span more than one line.

Copy link
Copy Markdown
Contributor

@beagleknight beagleknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, amazing job dude!

@codecov-io
Copy link
Copy Markdown

codecov-io commented Dec 12, 2016

Current coverage is 60.81% (diff: 72.22%)

Merging #334 into master will decrease coverage by 0.19%

@@             master       #334   diff @@
==========================================
  Files          3053       3004    -49   
  Lines        123661     122998   -663   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits          75435      74796   -639   
+ Misses        48226      48202    -24   
  Partials          0          0          

Powered by Codecov. Last update 5aba6f3...b17ce1c

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WUUUT nooooo monkeypatchingggg. Why can't you explicitly add this on the models that need this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was added by the Dragonfly generator, man. Anyway, I'm dropping all of this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this in the engine instead of the initializer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a cache storage instead of filesystem, as filesystem is volatile in some platforms like heroku.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a potential security risk, I'd rather create the avatar in a callback at the model

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think there are too many public params, and it could also be a way to guess users by ID.

@josepjaume
Copy link
Copy Markdown
Contributor

@oriolgual there's other options like https://github.com/lucek/avatarly

@oriolgual
Copy link
Copy Markdown
Contributor

@mrcasals
Copy link
Copy Markdown
Contributor Author

@josepjaume @oriolgual avatarly looks good enough, I can add it on user creation so that we have an avatar set. Do you prefer this over opening an endpoint?

@mrcasals
Copy link
Copy Markdown
Contributor Author

@josepjaume @oriolgual finally going to set a before_create hook on the User model to create the avatar.

@josepjaume
Copy link
Copy Markdown
Contributor

@mrcasals not sure a before_create hook is the way to go, as avatars will get created for each and every user even during tests. What about explicitly creating it on the user creation command, and re-generating it on the user edit command (which we don't have yet).

@oriolgual what do you think about this?

@josepjaume
Copy link
Copy Markdown
Contributor

I mean, one of the reasons the command pattern exists is to be able to make this kind of flows more explicit - callbacks tend to be problematic.

@oriolgual
Copy link
Copy Markdown
Contributor

Works for me @josepjaume

@mrcasals
Copy link
Copy Markdown
Contributor Author

@oriolgual @josepjaume we don't have a command for user registration, because this is done via Devise automatically.

@mrcasals
Copy link
Copy Markdown
Contributor Author

Update: in order to generate avatars, it looks like we need rmagick, and having both rmagick and minimagick does not work well. My proposal is using Gravatar, since it gives us some benefits:

  1. If the user already has an avatar set up, it shows this one
  2. If the user has no avatar, Gravatar returns a random one (or one specified by us)
  3. We don't need to save the avatars in our file system
  4. We can redirect the users to Gravatar if they want to change their avatar, so we don't need to handle anything about this.
  5. We can get avatars through a secure connection

Cons:

  1. We don't handle the avatars. I don't know if this can be a problem for any organization

@oriolgual already gave his OK offline. @josepjaume thoughts, please?

@oriolgual
Copy link
Copy Markdown
Contributor

Another benefit: we spend 10x less time on this feature xD

@josepjaume
Copy link
Copy Markdown
Contributor

josepjaume commented Dec 13, 2016

One of the goals of the project is to have 0 dependencies on external providers, so I'm -1 on this. Let's just put a default avatar placeholder and see if we can improve this later on.

@mrcasals
Copy link
Copy Markdown
Contributor Author

I'll set the default avatar to this for every user:

@mrcasals
Copy link
Copy Markdown
Contributor Author

@josepjaume @oriolgual should the system admins also have an avatar, or we can skip them?

@josepjaume
Copy link
Copy Markdown
Contributor

@mrcasals late to the party, but let's skip avatars for system admins xD

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused method argument - args. If it's necessary, use _ or _args as an argument name to indicate that it won't be used. You can also write as default_url(*) if you want the method to accept any arguments but don't care about them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused method argument - args. If it's necessary, use _ or _args as an argument name to indicate that it won't be used. You can also write as default_url(*) if you want the method to accept any arguments but don't care about them.

@josepjaume
Copy link
Copy Markdown
Contributor

You should talk with @beagleknight to standarize how avatars are shown in comments.

@mrcasals mrcasals merged commit e7e6c02 into master Dec 13, 2016
@mrcasals mrcasals deleted the add_fake_avatars branch December 13, 2016 12:46
aitorlb pushed a commit to CodiTramuntana/decidim that referenced this pull request Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants