Permalink
Browse files

Factor out user-attribute calls

  • Loading branch information...
1 parent 4bbf599 commit 17c085bc6b66558b3118afe907cd2aceb5e93d61 @chrismgray committed Dec 14, 2011
Showing with 6 additions and 4 deletions.
  1. +2 −2 src/foreclojure/problems.clj
  2. +2 −2 src/foreclojure/users.clj
  3. +2 −0 src/foreclojure/utils.clj
View
4 src/foreclojure/problems.clj
@@ -5,7 +5,7 @@
[ring.util.response :as response]
[cheshire.core :as json])
(:import [org.apache.commons.mail EmailException])
- (:use [foreclojure.utils :only [from-mongo get-user get-solved login-link flash-msg flash-error row-class approver? can-submit? send-email image-builder if-user with-user as-int maybe-update escape-html user-attribute]]
+ (:use [foreclojure.utils :only [from-mongo get-user get-solved login-link flash-msg flash-error row-class approver? can-submit? send-email image-builder if-user with-user as-int maybe-update escape-html user-id]]
[foreclojure.ring-utils :only [*url*]]
[foreclojure.template :only [def-page content-page]]
[foreclojure.social :only [tweet-link gist!]]
@@ -121,7 +121,7 @@
(maybe-update [old-score] dec)))))))))
(defn store-completed-state! [username problem-id code]
- (let [user-id ((user-attribute :_id) username)
+ (let [user-id (user-id username)
current-time (java.util.Date.)]
(when (not-any? #{problem-id} (get-solved username))
(update! :users {:_id user-id} {:$addToSet {:solved problem-id}
View
4 src/foreclojure/users.clj
@@ -20,7 +20,7 @@
[:golfer])))
(defn get-user-id [name]
- ((user-attribute :_id) name))
+ (user-id name))
(defn get-users []
(from-mongo
@@ -62,7 +62,7 @@
(true? (:hide-solutions user)))
(defn email-address [username]
- ((user-attribute :email) username))
+ (user-email username))
(defn mailto [username]
(link-to (str "mailto:" (email-address username))
View
2 src/foreclojure/utils.clj
@@ -194,6 +194,8 @@
(def get-solved (comp set (user-attribute :solved)))
(def approver? (user-attribute :approver))
+(def user-id (user-attribute :_id))
+(def user-email (user-attribute :email))
(defn can-submit? [username]
(or (approver? username)

0 comments on commit 17c085b

Please sign in to comment.