Ivan Melnikov avatar Ivan Melnikov committed 586aba2 Draft

Show all approved users

Comments (0)

Files changed (4)

template/static/js/user.js

 function approveUser(user_id) {
 	$.ajax({ 
-        type: 'POST', 
-        url: '/.user/all', 
+        type: 'PUT', 
+        url: '/.user', 
         data: 'user_id=' + user_id,
         cache: false, 
         success: function(message) 

template/user/add.html

+{% extends "index.html" %}
+
+{% block content %}
+
+<h1>Подтвердить</h1>
+
+{% for user in users %}
+<div id="{{ user.key().id() }}">
+{{ user.email }}
+<a href="#" onclick="approveUser( {{ user.key().id() }} )">Подтвердить</a>
+</div>
+
+{% endfor %}
+
+<a href="/.user/all">Все пользователи</a>
+
+{% endblock %}

template/user/list.html

 
 {% block content %}
 
+<a href="/.user">Подтвердить</a>
+
 <h1>Пользователи</h1>
 
 {% for user in users %}
 <div id="{{ user.key().id() }}">
 {{ user.email }}
-<a href="#" onclick="approveUser( {{ user.key().id() }} )">Подтвердить</a>
 </div>
 
 {% endfor %}
 
 class AddUser(webapp2.RequestHandler):
 
+	@auth
+	def get(self):
+		# get users to approve
+		users = User.all().filter('approved', None).fetch(1000)
+
+		template = jinja_environment.get_template('add.html')
+		self.response.out.write(template.render({'users': users}))
+
 	def post(self):
 		''' Create new user '''
 
 
 		self.redirect('/')
 
-
-class ListUser(webapp2.RequestHandler):
-
-	@auth
-	def get(self):
-		users = User.all().filter('approved', None).fetch(1000)
-
-		template = jinja_environment.get_template('list.html')
-		self.response.out.write(template.render({'users': users}))
-
-	def post(self):
+	def put(self):
 		# Approve user
 		user_id = self.request.get('user_id')
 		log.info('Approve user ' + user_id)
 		memcache.set(CACHE_AUTH+user.user_id, True)
 
 
+class ListUser(webapp2.RequestHandler):
+
+	@auth
+	def get(self):
+		users = User.all().filter('approved !=', None).order('-approved').fetch(1000)
+
+		template = jinja_environment.get_template('list.html')
+		self.response.out.write(template.render({'users': users}))
+
+
+
 debug = os.environ.get('SERVER_SOFTWARE', '').startswith('Dev')
 
 app = webapp2.WSGIApplication([('/.user', AddUser),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.