示例#1
0
文件: views.py 项目: rorycl/clwmail
def _domainmanageresponder(request, page_num=None, adict={}):

	''' 
		This method provides a mechanism for and admin user to manage domains.
		The decorator ensures that the user is an admin before proceeding. The
		page lists a paginated view of current domains.  add allows the admin
		to add more domains
	'''

	# Create model instance
	model = AdminModel()
	# default mode
	mode ='add'
	# Get all the domains in the 
	# system that are not admins
	domains = list(model.getalldomains())
	# Set page based on passed in number or session
	page = page_num or request.session.get('d_page',1)
	# Set the page number in the session
	request.session['d_page'] = page
	# Get collection and current page
	dcollection, domains_page = paginatorwrapper(domains, page, per_page=items_per_page, orphans=1)

	# The template vars
	info_dict = {'domains':domains_page,
				 'collection': dcollection,
				 'page':'dmanage',
				 'mode':mode,
				 'thistemplate':thistemplate}
	# update the template vars
	info_dict.update(adict)

	return render_to_response('admin/domainmanage.html',
							  info_dict,
							  context_instance=RequestContext(request))
示例#2
0
文件: views.py 项目: rorycl/clwmail
def _usermanageresponder(request, page_num=None, adict={}):
	''' 
		This method provides a mechanism for and admin user to mange people.
		The decorator ensures that the user is an admin before proceeding. The
		page lists a paginated view of current users.  add allows the admin to
		add more users
	'''
	
	# Create model instance
	model = AdminModel()
	# default mode
	mode ='add'
	# Get all the users in the 
	# system that are not admins
	users = list(model.getallusers())
	# Set page based on passed in number or session
	page = page_num or request.session.get('u_page',1)
	# Set the page number in the session
	request.session['u_page'] = page
	# Defaults
	ucollection, users_page = paginatorwrapper(users, page, per_page=items_per_page, orphans=1)
	# Get all available domains
	domains = list(model.getalldomains())
	# Generate a password
	generated_pass = _gen_pass()

	# The template vars
	info_dict = {'users':users_page,
				 'collection': ucollection,
				 'domains':domains,
				 'page':'umanage',
				 'gen_pass':generated_pass,
				 'mode':mode,
				 'types':types,
				 'thistemplate':thistemplate}

	# update the template vars
	info_dict.update(adict)

	return render_to_response('admin/usermanage.html', info_dict,
							   context_instance=RequestContext(request))