noosfero | WIP: Improvements on AccessLevel class, in order to center how noosfero display content to users. (!1361)

Rodrigo Souto gitlab at mg.gitlab.com
Tue Dec 19 13:20:04 BRST 2017


Rodrigo Souto started a new discussion on app/concerns/article_access_levels.rb:

> +  CHECK_BY_CONTENT = %w(owner? public? show_to_followers?)
> +
> +  def self.permission(user, profile, content = nil)
> +    return @@value if (high_permission || content.nil?)
> +    CHECK_BY_CONTENT.each do |method|
> +      send(method, user, profile, content)
> +    end
> +    @@value
> +  end
> +
> +  # This class methods implements validations to a user access some profile article
> +
> +  # If show_to_followers is false, either a member or a friend can't see
> +  # the content?
> +  def self.owner?(user, profile, content)
> +    @@value = mixed_levels[:self] if content.profile == user

I would use `||=` here as well just in case someone add a new `CHECK` before `owner?`.

---
Reply to this email directly or view it on GitLab: https://gitlab.com/noosfero/noosfero/merge_requests/1361#note_52003871
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20171219/b6ecf89a/attachment.html>


More information about the Noosfero-dev mailing list