add quick and dirty user list for mods
This commit is contained in:
		
							
								
								
									
										1
									
								
								app.lua
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								app.lua
									
									
									
									
									
								
							@@ -31,6 +31,7 @@ app:before_filter(inject_methods)
 | 
			
		||||
app:include("apps.users", {path = "/user"})
 | 
			
		||||
app:include("apps.topics", {path = "/topics"})
 | 
			
		||||
app:include("apps.threads", {path = "/threads"})
 | 
			
		||||
app:include("apps.mod", {path = "/mod"})
 | 
			
		||||
 | 
			
		||||
app:get("/", function(self)
 | 
			
		||||
  return {redirect_to = self:url_for("all_topics")}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										23
									
								
								apps/mod.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								apps/mod.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
local app = require("lapis").Application()
 | 
			
		||||
 | 
			
		||||
local util = require("util")
 | 
			
		||||
 | 
			
		||||
local models = require("models")
 | 
			
		||||
local Users = models.Users
 | 
			
		||||
 | 
			
		||||
app:get("user_list", "/list", function(self)
 | 
			
		||||
  self.me = util.get_logged_in_user(self)
 | 
			
		||||
  if not self.me then
 | 
			
		||||
    return {redirect_to = self:url_for("all_topics")}
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  if not self.me:is_mod() then
 | 
			
		||||
    return {redirect_to = self:url_for("all_topics")}
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  self.users = Users:select("")
 | 
			
		||||
  
 | 
			
		||||
  return {render = "mod.user-list"}
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
return app
 | 
			
		||||
@@ -7,6 +7,10 @@
 | 
			
		||||
  <span>
 | 
			
		||||
    <% if me and me:is_logged_in() then -%>
 | 
			
		||||
      Welcome, <a href="<%= url_for("user", {username = me.username}) %>"><%= me.username %></a>
 | 
			
		||||
      <% if me:is_mod() then %>
 | 
			
		||||
        •
 | 
			
		||||
        <a href="<%= url_for("user_list") %>">User list</a>
 | 
			
		||||
      <% end %>
 | 
			
		||||
    <% else -%>
 | 
			
		||||
      Welcome, guest. Please <a href="<%= url_for("user_signup") %>">sign up</a> or <a href="<%= url_for("user_login") %>">log in</a>
 | 
			
		||||
    <% end -%>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										8
									
								
								views/mod/user-list.etlua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								views/mod/user-list.etlua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
<div class="darkbg settings-container">
 | 
			
		||||
  <h1>All users</h1>
 | 
			
		||||
  <ul>
 | 
			
		||||
    <% for _, user in ipairs(users) do %>
 | 
			
		||||
      <li><a href="<%= url_for("user", {username = user.username}) %>"><%= user.username %></a></li>
 | 
			
		||||
    <% end %>
 | 
			
		||||
  </ul>
 | 
			
		||||
</div>
 | 
			
		||||
		Reference in New Issue
	
	Block a user