示例#1
0
 @Before
 static void setConnectedUser() {
   if (Security.isConnected()) {
     User user = User.find("byEmail", Security.connected()).first();
     renderArgs.put("user", user.fullname);
   }
 }
示例#2
0
 @Before
 static void setConnectedUser() {
   if (Security.isConnected()) {
     User user = User.find("byUsername", Security.connected()).first();
     if (!user.isAdmin) {
       flash.error(Messages.get("UserIsNotAuthorized"));
       Application.index();
     }
   }
 }
示例#3
0
  @Before
  static void setConnectedUser() {
    if (Security.isConnected()) {
      User user = User.find("byEmail", Security.connected()).first();

      if (user == null) {
        user = new User("*****@*****.**", "1234", "Andreas");
        user.save();
      }

      renderArgs.put("user", user.fullname);
    }
  }
示例#4
0
文件: Admin.java 项目: nateki/yabe
 public static void save(Long id, String title, String content, String tags) {
   Post post;
   if (id == null) {
     // Create post
     User author = User.find("byEmail", Security.connected()).first();
     post = new Post(author, title, content);
   } else {
     // Retrieve post
     post = Post.findById(id);
     // Edit
     post.title = title;
     post.content = content;
     post.tags.clear();
   }
   // Set tags list
   for (String tag : tags.split("\\s+")) {
     if (tag.trim().length() > 0) {
       post.tags.add(Tag.findOrCreateByName(tag));
     }
   }
   // Validate
   validation.valid(post);
   if (validation.hasErrors()) {
     render("@form", post);
   }
   // Save
   post.save();
   index();
 }
示例#5
0
  @Before
  static void header() {
    Journal journal = Journal.all().first();
    renderArgs.put("journal", journal);
    renderArgs.put("journalName", journal.name);
    renderArgs.put("journalDesc", journal.description);

    User currentUser = User.find("byEmail", Security.connected()).<User>first();
    renderArgs.put("currentUser", currentUser);
  }
  public static void salvar(@Valid Paciente paciente) {
    Security.deny();

    if (validation.hasErrors()) {
      flash.error("Favor corrigir os erros a seguir");
      render("@form", paciente);
    }
    paciente.save();
    flash.success("Salvo com sucesso");
    Nutricionistas.index();
  }
示例#7
0
 public static void uploadFile(String filename, File file) {
   User user = User.find("byEmail", Security.connected()).first();
   Upload uploadObj = new Upload();
   uploadObj.UploadFile(filename, user, file);
   Admin.upload();
 }
示例#8
0
文件: Admin.java 项目: nateki/yabe
 public static void index() {
   String user = Security.connected();
   List<Post> posts = Post.find("author.email", user).fetch();
   render(posts);
 }