Browse Source
This mostly sets up the basic CRUD operations you normally find on a website. There is some code for CSRF, also. There is one major bit of malfunctioning coding though. It is the 'setf' bit of code. I have tried to rearrange the code to see if I can get it to work but I simply cannot work it out. I have decided to leave the code as it is described in the tutorial (for Chapter 6) and hope there is some incite in future chapters to help me fix the problem.master
Craig Oates
2 years ago
10 changed files with 386 additions and 19 deletions
@ -0,0 +1,25 @@ |
|||||||
|
{% extends "layouts/app.html" %} |
||||||
|
{% block title %} |
||||||
|
{% lisp (title! "Edit User") %} |
||||||
|
{% endblock %} |
||||||
|
|
||||||
|
{% block content %} |
||||||
|
<h1>{% lisp (title!) %}</h1> |
||||||
|
|
||||||
|
<div class="toolbar"> |
||||||
|
<a href="/users/{{user.id}}">Back to user detail</a> |
||||||
|
</div> |
||||||
|
|
||||||
|
<form class="edit-user" id="edit-user" |
||||||
|
action="/user/{{user.id}}" method="post"> |
||||||
|
<input name="_method" type="hidden" value="patch"/> |
||||||
|
<input name="authenticity-token" type="hidden" value="{{token}}"/> |
||||||
|
|
||||||
|
{% include "users/form.html" %} |
||||||
|
|
||||||
|
<div> |
||||||
|
<input type="submit" name="commit" value="edit user"/> |
||||||
|
</div> |
||||||
|
|
||||||
|
</form> |
||||||
|
{% endblock %} |
@ -0,0 +1,96 @@ |
|||||||
|
<table class="attr"> |
||||||
|
<tr> |
||||||
|
<th><label for="user-number">Number</label></th> |
||||||
|
<td><input size="8" type="text" name="number" |
||||||
|
value="{{user.number}}" id="user-number"/></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<th><label for="user-name">Name</label></th> |
||||||
|
<td><input type="text" name="name" |
||||||
|
value="{{user.name}}" |
||||||
|
id="user-name"/></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<th><label for="user-full-name">Full Name</label></th> |
||||||
|
<td><input type="text" value="{{user.full-name}}" |
||||||
|
name="full-name" id="user-full-name"/></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<th>Sex</th> |
||||||
|
<td> |
||||||
|
<input type="radio" value="1" |
||||||
|
{% ifequal user.sex 1 %}checked="checked"{% endifequal %} |
||||||
|
name="sex" id="member-sex-1"/> |
||||||
|
<label for="member-sex-1">Male</label> |
||||||
|
<input type="radio" value="2" |
||||||
|
{% ifequal user.sex 2 %}checked="checked"{% endifequal %} |
||||||
|
name="sex" id="member-sex-2"/> |
||||||
|
<label for="member-sex-2">Female</label> |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
|
||||||
|
<tr> |
||||||
|
<th><label for="user-email">Email</label></th> |
||||||
|
<td><input type="text" name="email" id="user-email"/></td> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<th>Administration</th> |
||||||
|
<td> |
||||||
|
<input name="administrator" type="hidden" value="0"/> |
||||||
|
<input type="checkbox" value="1" name="administrator" id="user-administrator"/> |
||||||
|
<label for="user-administrator">Administrator</label> |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
|
||||||
|
<tr> |
||||||
|
<th><label for="user-birthday">Birthday</label></th> |
||||||
|
<td> |
||||||
|
<select id="member-birthday-li" name="birthday-year"> |
||||||
|
{{ user.birthday |
||||||
|
| lisp: (lambda(timestamp) |
||||||
|
(let((current-year(local-time:timestamp-year(local-time:now)))) |
||||||
|
(loop :for i :upfrom 1940 :to current-year |
||||||
|
:with target = (or (and timestamp |
||||||
|
(local-time:timestamp-year timestamp)) |
||||||
|
(- current-year 20)) |
||||||
|
:collect (format nil "<option value=\"~D\"~@[ ~A~]>~2:*~D</option>~%" |
||||||
|
i (when(= target i) |
||||||
|
"selected=\"selected\""))))) |
||||||
|
| join:"" |
||||||
|
| safe |
||||||
|
}} |
||||||
|
</select> |
||||||
|
<select id="member-birthday-2i" name="birthday-month"> |
||||||
|
{{ user.birthday |
||||||
|
| lisp: (lambda(timestamp) |
||||||
|
(loop :for i :upfrom 1 to 12 |
||||||
|
:with target = (or (and timestamp |
||||||
|
(local-time:timestamp-month timestamp)) |
||||||
|
1) |
||||||
|
:collect (format nil "<option value=\"~D\"~@[ ~A~]>~A</option>~%" |
||||||
|
i (when(= target i) |
||||||
|
"selected=\"selected\"") |
||||||
|
(aref local-time:+month-names+ i)))) |
||||||
|
| join:"" |
||||||
|
| safe |
||||||
|
}} |
||||||
|
</select> |
||||||
|
<select id="birthday-3i" name="birthday-day"> |
||||||
|
{{ user.birthday |
||||||
|
| lisp: (lambda(timestamp) |
||||||
|
(loop :for i :upfrom 1 to 31 |
||||||
|
:with target = (or (and timestamp |
||||||
|
(local-time:timestamp-day timestamp)) |
||||||
|
1) |
||||||
|
:collect (format nil "<option value=\"~D\"~@[ ~A~]>~2:*~D</option>~%" |
||||||
|
i (when(= target i) |
||||||
|
"selected=\"selected\"")))) |
||||||
|
| join:"" |
||||||
|
| safe |
||||||
|
}} |
||||||
|
</select> |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
|
||||||
|
|
||||||
|
</table> |
@ -0,0 +1,21 @@ |
|||||||
|
{% extends "layouts/app.html" %} |
||||||
|
{% block title %} |
||||||
|
{% lisp (title! "New member") %} |
||||||
|
{% endblock %} |
||||||
|
|
||||||
|
{% block content %} |
||||||
|
<h1>{% lisp (title!) %}</h1> |
||||||
|
<p>{{token}}</p> |
||||||
|
<form class="new-user" id="new-user" action="/user" method="post"> |
||||||
|
<input name="authenticity-token" type="hidden" value="{{token}}" /> |
||||||
|
{% include "users/form.html" %} |
||||||
|
<div> |
||||||
|
<input type="submit" name="commit" value="create user" /> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
{% endblock %} |
||||||
|
|
||||||
|
{% extends "layouts/app.html" %} |
||||||
|
{% block title %} |
||||||
|
{% lisp (title! "New member") %} |
||||||
|
{% endblock %} |
Loading…
Reference in new issue