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

View file

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

View file

@ -17,7 +17,7 @@
<h3> <h3>
<span tal:content="comment/subject">Subject</span></h3> <span tal:content="comment/subject">Subject</span></h3>
<div class="info"> <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> <span tal:replace="comment/timeStamp">2007-03-30</span>
</div> </div>
<p class="content" <p class="content"
@ -44,6 +44,18 @@
<input type="hidden" name="contentType" value="text/restructured" /> <input type="hidden" name="contentType" value="text/restructured" />
<div class="heading" i18n:translate="">Add Comment</div> <div class="heading" i18n:translate="">Add Comment</div>
<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="" <label i18n:translate=""
for="comment_subject">Subject</label> for="comment_subject">Subject</label>
<div><input type="text" name="subject" id="comment_subject" <div><input type="text" name="subject" id="comment_subject"