allow anonymous posters

This commit is contained in:
Helmut Merz 2014-02-11 11:44:21 +01:00
parent f8849ee393
commit 6e901de066
4 changed files with 31 additions and 4 deletions

Binary file not shown.

View file

@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: 0.13.0\n"
"POT-Creation-Date: 2007-05-22 12:00 CET\n"
"PO-Revision-Date: 2013-07-15 12:00 CET\n"
"PO-Revision-Date: 2014-02-11 12:00 CET\n"
"Last-Translator: Helmut Merz <helmutm@cy55.de>\n"
"Language-Team: loops developers <helmutm@cy55.de>\n"
"MIME-Version: 1.0\n"
@ -888,6 +888,9 @@ msgstr "Kommentare"
msgid "Add Comment"
msgstr "Kommentar hinzufügen"
msgid "Email Address"
msgstr "E-Mail-Adresse"
msgid "Subject"
msgstr "Thema"

View file

@ -86,6 +86,13 @@ class CommentsView(NodeView):
class CommentDetails(TrackDetails):
@Lazy
def poster(self):
name = self.track.data.get('name')
if name:
return name
return self.user['title']
@Lazy
def subject(self):
return self.track.data['subject']
@ -115,6 +122,8 @@ class CreateComment(EditObject):
@Lazy
def personId(self):
if self.view.isAnonymous:
return self.request.form.get('email')
p = getPersonForUser(self.context, self.request)
if p is not None:
return util.getUidForObject(p)
@ -136,8 +145,11 @@ class CreateComment(EditObject):
if ts is None:
ts = addObject(rm, TrackingStorage, 'comments', trackFactory=Comment)
uid = util.getUidForObject(self.object)
ts.saveUserTrack(uid, 0, self.personId, dict(
subject=subject, text=text))
data = dict(subject=subject, text=text)
for k in ('name', 'email'):
if k in form:
data[k] = form[k]
ts.saveUserTrack(uid, 0, self.personId, data)
url = self.view.virtualTargetUrl + '?version=this'
self.request.response.redirect(url)
return False

View file

@ -17,7 +17,7 @@
<h3>
<span tal:content="comment/subject">Subject</span></h3>
<div class="info">
<span tal:replace="comment/user/title">John</span>,
<span tal:replace="comment/poster">John</span>,
<span tal:replace="comment/timeStamp">2007-03-30</span>
</div>
<p class="content"
@ -44,6 +44,18 @@
<input type="hidden" name="contentType" value="text/restructured" />
<div class="heading" i18n:translate="">Add Comment</div>
<div>
<tal:anonymous condition="view/isAnonymous">
<label i18n:translate=""
for="comment_name">Name</label>
<div><input type="text" name="name" id="comment_name"
dojoType="dijit.form.ValidationTextBox" required="true"
style="width: 60em" /></div>
<label i18n:translate=""
for="comment_email">Email Address</label>
<div><input type="text" name="email" id="comment_email"
dojoType="dijit.form.ValidationTextBox" required="true"
style="width: 60em" /></div>
</tal:anonymous>
<label i18n:translate=""
for="comment_subject">Subject</label>
<div><input type="text" name="subject" id="comment_subject"