Permalink
Browse files

user model: isAffiliationAtLeast reuses app.affiliations

  • Loading branch information...
1 parent 71dbb6a commit 70bde17c5f67f945b4f023a77995e7bfd6ce712d @astro astro committed Mar 3, 2012
Showing with 4 additions and 11 deletions.
  1. +4 −11 src/models/user.coffee
View
@@ -81,15 +81,8 @@ class exports.User extends Model
no
-# Copied from server operations
-AFFILIATIONS = [
- 'outcast', 'none', 'member',
- 'publisher', 'moderator', 'owner'
-]
+# app.affiliations is sorted descending
isAffiliationAtLeast = (affiliation1, affiliation2) ->
- i1 = AFFILIATIONS.indexOf(affiliation1)
- i2 = AFFILIATIONS.indexOf(affiliation2)
- if i2 < 0
- false
- else
- i1 >= i2
+ i1 = app.affiliations.indexOf(affiliation1 or 'none')
+ i2 = app.affiliations.indexOf(affiliation2 or 'none')
+ return i1 >= i2

0 comments on commit 70bde17

Please sign in to comment.