extends vibelog.admin.layout

block vibelog.title
	- title = "Edit user '"~info.user.username~"'";

block vibelog-localnav
	ul.admin-local-nav
		li
			a(href="../") Back to user list

block vibelog-content
	- import std.datetime;

	form(action="./", method="POST")
		input(type="hidden", name="id", value="#{info.user._id.toString()}")
		p
			label(for="username") Username
			input(type="text", name="username", value="#{info.user.username}")
		p
			label(for="name") Full name
			input(type="text", name="name", value="#{info.user.name}")
		p
			label(for="email") Email
			input(type="email", name="email", value="#{info.user.email}")
		- if (!info.loginUser.isUserAdmin())
			p
				label(for="oldPassword") Current Password
				input(type="password", name="oldPassword", value="")
		p
			label(for="password") New Password
			input(type="password", name="password", value="")
		p
			label(for="passwordConfirmation") Confim new password
			input(type="password", name="passwordConfirmation", value="")
		- if (info.loginUser.isUserAdmin())
			p Groups:
			p
				- foreach( grp; info.globalConfig.groups )
					- if( info.user.inGroup(grp) )
						input.checkbox(type="checkbox", name="group_#{grp}", value="1", checked)
					- else
						input.checkbox(type="checkbox", name="group_#{grp}", value="1")
					label(for="group_#{grp}")= grp
					br
			p Allowed categories:
			p
				- foreach( grp; info.globalConfig.categories )
					- if( info.user.mayPostInCategory(grp) )
						input.checkbox(type="checkbox", name="category_#{grp}", value="1", checked)
					- else
						input.checkbox(type="checkbox", name="category_#{grp}", value="1")
					label(for="category_#{grp}")= grp
					br
		input(type="submit", value="Apply changes")
