incubator-esme-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vdic...@apache.org
Subject svn commit: r777202 - in /incubator/esme/branches/access-pools/server/src/main: scala/org/apache/esme/model/AccessPool.scala scala/org/apache/esme/model/Privilege.scala scala/org/apache/esme/snippet/UserSnip.scala webapp/templates-hidden/message.html
Date Thu, 21 May 2009 17:56:50 GMT
Author: vdichev
Date: Thu May 21 17:56:43 2009
New Revision: 777202

URL: http://svn.apache.org/viewvc?rev=777202&view=rev
Log:
ESME-55 Web UI for sending a message to an access pool

Modified:
    incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/model/AccessPool.scala
    incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/model/Privilege.scala
    incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala
    incubator/esme/branches/access-pools/server/src/main/webapp/templates-hidden/message.html

Modified: incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/model/AccessPool.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/model/AccessPool.scala?rev=777202&r1=777201&r2=777202&view=diff
==============================================================================
--- incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/model/AccessPool.scala
(original)
+++ incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/model/AccessPool.scala
Thu May 21 17:56:43 2009
@@ -59,6 +59,8 @@
     case Nil => Full(this.name(in))
     case List(_,_*) => Failure("Duplicate access pool name!")
   }
+  
+  def getName() = name.is
 
   private def sameName(name: String) = 
     AccessPool.findAll(By(AccessPool.name, name)).

Modified: incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/model/Privilege.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/model/Privilege.scala?rev=777202&r1=777201&r2=777202&view=diff
==============================================================================
--- incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/model/Privilege.scala
(original)
+++ incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/model/Privilege.scala
Thu May 21 17:56:43 2009
@@ -38,6 +38,11 @@
   def findViewablePools(userId: Long) = Privilege.findMap(
     By(Privilege.user, userId)
   )(p => Full(p.pool.is))
+
+  def findWritablePools(userId: Long) = Privilege.findMap(
+    By(Privilege.user, userId),
+    NotBy(Privilege.permission, Permission.Read)
+  )(p => Full(p.pool.is))
 }
 
 class Privilege extends LongKeyedMapper[Privilege] {

Modified: incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala
URL: http://svn.apache.org/viewvc/incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala?rev=777202&r1=777201&r2=777202&view=diff
==============================================================================
--- incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala
(original)
+++ incubator/esme/branches/access-pools/server/src/main/scala/org/apache/esme/snippet/UserSnip.scala
Thu May 21 17:56:43 2009
@@ -48,6 +48,11 @@
           case _ => Empty
         }
         
+        val pool = map.get("access_pool").map(toLong) match {
+          case Some(x) if x > 0L => Some(x)
+          case _ => None
+        }
+        
         Distributor ! 
         Distributor.UserCreatedMessage(user.id, msg, 
                                        Tag.split(tags),
@@ -55,7 +60,7 @@
                                        Empty,
                                        "web",
                                        replyTo,
-                                       None)
+                                       pool)
                                        
       }
       Noop
@@ -71,7 +76,8 @@
       "followers" -> followers _,
       "following" -> following _,
       "loginForm" -> loginForm _,
-      "loggedIn" -> loggedInFilter _)
+      "loggedIn" -> loggedInFilter _,
+      "accessPools" -> accessPools _)
 
   def loggedInFilter(in: NodeSeq): NodeSeq = {
     val lookFor = if (User.loggedIn_?) "in" else "out"
@@ -113,6 +119,15 @@
     Text(User.currentUser.map(_.wholeName) openOr "")
   }
 
+  def accessPools(in: NodeSeq): NodeSeq = {
+    for(user <- User.currentUser.toSeq;
+        p    <- Privilege.findWritablePools(user.id))
+        // slow?
+      yield <option value={p}>
+              {AccessPool.find(p).get.getName}
+            </option>
+  }
+  
   def postScript(in: NodeSeq): NodeSeq =
   <xml:group>
     {Script(JsonPoster.is._2)}
@@ -120,9 +135,11 @@
                      JsonPoster.is._1("post",
                                       JsObj("msg" -> ValById("textdude"),
                                             "tags" -> ValById("tagdude"),
+                                            "access_pool" -> ValById("access_pool"),
                                             "reply-to" -> JsVar("currentConvNumber")))
&
                      SetValById("textdude", "") &
                      SetValById("tagdude", "") &
+                     SetValById("access_pool", "0") &
                      JsRaw("clearReplyTo();")
         ))
     }

Modified: incubator/esme/branches/access-pools/server/src/main/webapp/templates-hidden/message.html
URL: http://svn.apache.org/viewvc/incubator/esme/branches/access-pools/server/src/main/webapp/templates-hidden/message.html?rev=777202&r1=777201&r2=777202&view=diff
==============================================================================
--- incubator/esme/branches/access-pools/server/src/main/webapp/templates-hidden/message.html
(original)
+++ incubator/esme/branches/access-pools/server/src/main/webapp/templates-hidden/message.html
Thu May 21 17:56:43 2009
@@ -242,6 +242,14 @@
                     </div>
                   </div>
 
+                  <div class="row clear">
+                    <label>Access pool</label>
+                    <select id="access_pool">
+                      <option id="0">--public--</option>
+                      <lift:UserSnip.accessPools />
+                    </select>
+                  </div>
+
                   <div class="row clear"><a class="btn" href="javascript:post_msg();"><img
src="/images/send-message.png" alt="Send Message" /></a></div>
 
                   <script>



Mime
View raw message