Commits

Ron Huang committed c8987dc

Renamed username to email.

Comments (0)

Files changed (2)

             <form action="" method="post" accept-charset="utf-8">
               <fieldset>
                 <div class="clearfix">
-                  <label for="username">Username</label>
+                  <label for="email">Email</label>
                   <div class="input">
-                    <input class="xlarge" id="username" name="username" size="30" type="text" placeholder="Type username here...">
+                    <input class="xlarge" id="email" name="email" size="30" type="text" placeholder="Type email here...">
                   </div>
                 </div>
                 <div class="clearfix">
                   <div class="input">
                     <select name="role" id="role">
                       <option>user</option>
-                      <option>admin</option>
                     </select>
                   </div>
                 </div>
     self.response.out.write(template.render("admin.html", context))
 
   def post(self):
-    username = self.request.get("username")
+    email = self.request.get("email")
     role = self.request.get("role")
-    if not username or not role:
+    if not email or not role:
       return self.redirect("/admin")
 
     # check if exist
-    
+    uacl = acl.Acl(email)
+    if uacl.is_one(role):
+      return self.redirect("/admin")
+
+    urole = acl.Role(user=email, role=role)
+    urole.put()
 
     return self.redirect("/admin")