summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorazul <azul@leap.se>2014-07-09 13:25:31 +0200
committerazul <azul@leap.se>2014-07-09 13:25:31 +0200
commitdc740e4311101bf7297996788b25a99edafbe759 (patch)
treed989456179551fb167f6c41ba4b54bbd4a77a7ac /app/models
parent19da5429308412c19176733d2b32ccbf2c08df1c (diff)
parent0cc11ebb609de225fbeacbf80788b992b88b6ce6 (diff)
Merge pull request #173 from azul/feature/unblock-handles
Allow admins to unblock handles
Diffstat (limited to 'app/models')
-rw-r--r--app/models/identity.rb24
-rw-r--r--app/models/user.rb4
2 files changed, 28 insertions, 0 deletions
diff --git a/app/models/identity.rb b/app/models/identity.rb
index e7b5785..eb67b1b 100644
--- a/app/models/identity.rb
+++ b/app/models/identity.rb
@@ -46,6 +46,10 @@ class Identity < CouchRest::Model::Base
end
+ def self.address_starts_with(query)
+ self.by_address.startkey(query).endkey(query + "\ufff0")
+ end
+
def self.for(user, attributes = {})
find_for(user, attributes) || build_for(user, attributes)
end
@@ -95,6 +99,18 @@ class Identity < CouchRest::Model::Base
}
end
+ def status
+ return :blocked if disabled?
+ case destination
+ when address
+ :main_email
+ when /@#{APP_CONFIG[:domain]}\Z/i,
+ :alias
+ else
+ :forward
+ end
+ end
+
def enabled?
self.user_id
end
@@ -103,6 +119,14 @@ class Identity < CouchRest::Model::Base
!enabled?
end
+ def actions
+ if enabled?
+ [] # [:show, :edit]
+ else
+ [:destroy]
+ end
+ end
+
def disable
self.destination = nil
self.user_id = nil
diff --git a/app/models/user.rb b/app/models/user.rb
index f8b9ddc..6bc5841 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -42,6 +42,10 @@ class User < CouchRest::Model::Base
view :by_created_at
end # end of design
+ def self.login_starts_with(query)
+ self.by_login.startkey(query).endkey(query + "\ufff0")
+ end
+
def reload
@identity = nil
super