Merge lp:~acoconut/systers/flexible_essays into lp:systers

Proposed by Ana Cutillas
Status: Superseded
Proposed branch: lp:~acoconut/systers/flexible_essays
Merge into: lp:systers
Diff against target: 212 lines (+109/-19)
4 files modified
Mailman/Cgi/listinfo.py (+24/-7)
Mailman/Cgi/subscribe.py (+28/-6)
Mailman/DlistUtils.py (+56/-0)
bin/rmlist (+1/-6)
To merge this branch: bzr merge lp:~acoconut/systers/flexible_essays
Reviewer Review Type Date Requested Status
Robin J Needs Fixing
beachbrake Pending
Review via email: mp+116732@code.launchpad.net

This proposal has been superseded by a proposal from 2012-07-27.

Description of the change

I added all the STORM related code that you can read in DlistUtils.py. Ignore the function acceptAnswer, I haven't worked on it yet.

I also made changes to subscribe.py.

Basically, when a form has more than one field with the same name (in our case, "essay"), CGI makes a list out of it. So I loop through the list to insert to the database. But if there's only one field (OR only one field has been filled/checked), CGI sends you the information as a string. Thus the if clause.

I can't figure out how to get the version of the questions to insert it to the database. Right now I left it with a 1... ideas? Maybe I could store the last version number to the pck file, is that a horrible idea? And then retrieve it from the subscribe.py file? We can talk about this through a normal email if you want.

To post a comment you must log in.
Revision history for this message
Robin J (robin-jeffries) wrote :

I would move the comment "added to support subscribe essays" up to the if statement, as right now it looks like just that one line was added for the essays.

I would also suggest that you mark lines that are just for your debugging with a comment like "debugging" so that a) I can tell that's what they are, and b) you can find them to remove them later. I assume lines 53, 55-57 are debugging statements?

Why is replacements['<mm-essay-box>'] always ''? Shouldn't you just get rid of it?

In subscribe.py you should make sure that the essay variable that is passed in is the same type (a list?) whether there is just one question or many (I can't see where you construct that data structure -- where does that happen?)

 (in subscribe.py) It seems pretty dangerous to have the question label just be the order in which you process the questions. Python does not guarantee that in a loop that says

for foo in foo_list:

that you will process each foo in the same order every time. Also, what happens if I reorder these questions (you don't have that functionality yet, but you need it)? Do you want them to have different question numbers? I think you want the question name (like 'talk') here.

You also seem to have hard coded the version to 1. Why is that?

In DlistUtils.py, the FormQuestion class, why are you putting together that command statement, that seems just to put something in the info log, when your next statement does it more directly? That confused me for quite a while.

If form_question_id is autoupdating, then what are you doing in line 144?

In DlistUtils.py, where did you add remove_dlist() I don't see it.

review: Needs Fixing
Revision history for this message
Robin J (robin-jeffries) wrote :

Just read your comments. Sorry.

1. You are telling me you have no control of whether the essay comes in as a list or a string. OK (at least I don't have the knowledge to override it)

2. version ought to be stored with the question. You would update the version whenever someone edits the question rather than replaces it (I would think an edit would be one of several types
    -wording change
    - answer type

So I would start when someone creates a question as version 1, and then when it is edited, that gets incremented. So it's part of the definition of the question (like the question text), and you don't need to store it in the pck file (every question could be a different version level.).

I think the big reason you don't understand version yet is that you haven't figured out what you are going to do with it. If you were to sketch out what the UI is going to look like for the administrator, when they go to approve these folks, and then think about what you want it to look like if you have two people with a) different versions of the same question, b) different questions, that might help you figure out where you want to keep the version number.

Revision history for this message
Ana Cutillas (acoconut) wrote :
Download full text (3.9 KiB)

On Fri, Jul 27, 2012 at 6:47 AM, Robin J <email address hidden> wrote:

> Review: Needs Fixing
>
> I would move the comment "added to support subscribe essays" up to the if
> statement, as right now it looks like just that one line was added for the
> essays.
>

OK, done.

>
> I would also suggest that you mark lines that are just for your debugging
> with a comment like "debugging" so that a) I can tell that's what they are,
> and b) you can find them to remove them later. I assume lines 53, 55-57
> are debugging statements?
>

Line 53 is not mine and it looks to me that when somebody is logging
through syslog for debugging, they write to the info file, in this line
they're writing to the error log, so maybe they wanted to keep a log of
this error every time it happens? I can add the if DEBUG_MODE statement if
you think it shouldn't be always stored. Let me know.

55-57 was junk, I got rid of it.

> Why is replacements['<mm-essay-box>'] always ''? Shouldn't you just get
> rid of it?
>

Yes, we're not using the replacements['mm-essay-box'] anymore, this might
mean some cleaning up is due in all the template related files. I'll leave
this for the end when I do the cleaning up.

> In subscribe.py you should make sure that the essay variable that is
> passed in is the same type (a list?) whether there is just one question or
> many (I can't see where you construct that data structure -- where does
> that happen?)
>
> (in subscribe.py) It seems pretty dangerous to have the question label
> just be the order in which you process the questions. Python does not
> guarantee that in a loop that says
>
> for foo in foo_list:
>
> that you will process each foo in the same order every time. Also, what
> happens if I reorder these questions (you don't have that functionality
> yet, but you need it)? Do you want them to have different question
> numbers? I think you want the question name (like 'talk') here.
>

Mmm... are you suggesting using the question name as the question ID? That
would work.

>
> You also seem to have hard coded the version to 1. Why is that?
>
> In DlistUtils.py, the FormQuestion class, why are you putting together
> that command statement, that seems just to put something in the info log,
> when your next statement does it more directly? That confused me for quite
> a while.
>

I know, it confused me too, but it's what every other class does! So I
thought it was something you guys had agreed on?

> If form_question_id is autoupdating, then what are you doing in line 144?
>

Line 144 is not mine or close to mine, I wrote around the 300 lines.

>
>
> In DlistUtils.py, where did you add remove_dlist() I don't see it.
>

I haven't done anything about removing dlists. Had we talk about something
like that?

From your other email:

2. version ought to be stored with the question. You would update the
> version whenever someone edits the question rather than replaces it (I
> would think an edit would be one of several types
> -wording change
> - answer type
>
> So I would start when someone creates a question as version 1, and then
> when it is edited, that gets incremented. So it's part of the definition
> of the qu...

Read more...

Revision history for this message
Ana Cutillas (acoconut) wrote :
Download full text (5.9 KiB)

>
>
> In subscribe.py you should make sure that the essay variable that is
> passed in is the same type (a list?) whether there is just one question or
> many (I can't see where you construct that data structure -- where does
> that happen?)
> (in subscribe.py) It seems pretty dangerous to have the question label
> just be the order in which you process the questions. Python does not
> guarantee that in a loop that says
> for foo in foo_list:
> that you will process each foo in the same order every time. Also, what
> happens if I reorder these questions (you don't have that functionality
> yet, but you need it)? Do you want them to have different question
> numbers? I think you want the question name (like 'talk') here.
>
>
Mmm... are you suggesting using the question name as the question ID? That
> would work.

Ok, I remember now what the problem was with this.

There are two ways I could go about naming the fields in the form.

1. I could give them the questions names, i.e. woman, talk, etc. That would
go perfect when writing to the database because I could use that word as
the ID. BUT, if I do this, when I have to retrieve the fields I don't know
how many of them there are, or how to retrieve them all. I don't know if
there's anyway of changing the structure that Cgi uses to send the content
of the form, or how to add info to this structure.

2. I could give them all the same name: essay. This is what I'm doing now.
But then, you said that the for loop doesn't guarantee that I'll be going
through the questions always in the same order, and I can't store the
question name because I don't have it - cgi doesn't send it, it only sends
the content of the fields. Well, it sends the name of the checkboxes (It
doesn't send true or false, it either sends woman, or it doesn't send
anything)

So clearly the cgi approach is quite flakey for what we're trying to do
now... what are your thoughts?

>
> On Fri, Jul 27, 2012 at 6:47 AM, Robin J <email address hidden> wrote:
>
>> Review: Needs Fixing
>>
>> I would move the comment "added to support subscribe essays" up to the if
>> statement, as right now it looks like just that one line was added for the
>> essays.
>>
>
> OK, done.
>
>>
>> I would also suggest that you mark lines that are just for your debugging
>> with a comment like "debugging" so that a) I can tell that's what they are,
>> and b) you can find them to remove them later. I assume lines 53, 55-57
>> are debugging statements?
>>
>
> Line 53 is not mine and it looks to me that when somebody is logging
> through syslog for debugging, they write to the info file, in this line
> they're writing to the error log, so maybe they wanted to keep a log of
> this error every time it happens? I can add the if DEBUG_MODE statement if
> you think it shouldn't be always stored. Let me know.
>
> 55-57 was junk, I got rid of it.
>
>
>> Why is replacements['<mm-essay-box>'] always ''? Shouldn't you just get
>> rid of it?
>>
>
> Yes, we're not using the replacements['mm-essay-box'] anymore, this might
> mean some cleaning up is due in all the template related files. I'll leave
> this for the end when I do the cleaning up.
>
>
>> In subscribe.py you s...

Read more...

Revision history for this message
Ana Cutillas (acoconut) wrote :
Download full text (6.3 KiB)

On Fri, Jul 27, 2012 at 8:12 PM, Ana Cutillas <email address hidden> wrote:

>
>> In subscribe.py you should make sure that the essay variable that is
>> passed in is the same type (a list?) whether there is just one question or
>> many (I can't see where you construct that data structure -- where does
>> that happen?)
>> (in subscribe.py) It seems pretty dangerous to have the question label
>> just be the order in which you process the questions. Python does not
>> guarantee that in a loop that says
>> for foo in foo_list:
>> that you will process each foo in the same order every time. Also, what
>> happens if I reorder these questions (you don't have that functionality
>> yet, but you need it)? Do you want them to have different question
>> numbers? I think you want the question name (like 'talk') here.
>>
>>
> Mmm... are you suggesting using the question name as the question ID? That
>> would work.
>
>
> Ok, I remember now what the problem was with this.
>
> There are two ways I could go about naming the fields in the form.
>
> 1. I could give them the questions names, i.e. woman, talk, etc. That
> would go perfect when writing to the database because I could use that word
> as the ID. BUT, if I do this, when I have to retrieve the fields I don't
> know how many of them there are, or how to retrieve them all. I don't know
> if there's anyway of changing the structure that Cgi uses to send the
> content of the form, or how to add info to this structure.
>

I could read the pck file again in the subscribe file, get the name and
number of questions and check against the info brought by the cgi module.
How does that sound?

> 2. I could give them all the same name: essay. This is what I'm doing now.
> But then, you said that the for loop doesn't guarantee that I'll be going
> through the questions always in the same order, and I can't store the
> question name because I don't have it - cgi doesn't send it, it only sends
> the content of the fields. Well, it sends the name of the checkboxes (It
> doesn't send true or false, it either sends woman, or it doesn't send
> anything)
>
> So clearly the cgi approach is quite flakey for what we're trying to do
> now... what are your thoughts?
>
>
>
>
>>
>> On Fri, Jul 27, 2012 at 6:47 AM, Robin J <email address hidden> wrote:
>>
>>> Review: Needs Fixing
>>>
>>> I would move the comment "added to support subscribe essays" up to the
>>> if statement, as right now it looks like just that one line was added for
>>> the essays.
>>>
>>
>> OK, done.
>>
>>>
>>> I would also suggest that you mark lines that are just for your
>>> debugging with a comment like "debugging" so that a) I can tell that's what
>>> they are, and b) you can find them to remove them later. I assume lines
>>> 53, 55-57 are debugging statements?
>>>
>>
>> Line 53 is not mine and it looks to me that when somebody is logging
>> through syslog for debugging, they write to the info file, in this line
>> they're writing to the error log, so maybe they wanted to keep a log of
>> this error every time it happens? I can add the if DEBUG_MODE statement if
>> you think it shouldn't be always stored. Let me know.
>>
>> 55-57 was junk, I got rid of...

Read more...

lp:~acoconut/systers/flexible_essays updated
89. By Ana Cutillas <email address hidden>

Made changes to the database and to the way we store the answers. Made
changes to the way we handle the information coming from the form.

90. By Ana Cutillas <email address hidden>

Cleaned up listinfo.py

Revision history for this message
Robin J (robin-jeffries) wrote :
Download full text (5.3 KiB)

On Fri, Jul 27, 2012 at 10:43 AM, Ana Cutillas <email address hidden> wrote:

> On Fri, Jul 27, 2012 at 6:47 AM, Robin J <email address hidden> wrote:
>
> > Review: Needs Fixing
> >
> > I would move the comment "added to support subscribe essays" up to the if
> > statement, as right now it looks like just that one line was added for
> the
> > essays.
> >
>
> OK, done.
>
> >
> > I would also suggest that you mark lines that are just for your debugging
> > with a comment like "debugging" so that a) I can tell that's what they
> are,
> > and b) you can find them to remove them later. I assume lines 53, 55-57
> > are debugging statements?
> >
>
> Line 53 is not mine and it looks to me that when somebody is logging
> through syslog for debugging, they write to the info file, in this line
> they're writing to the error log, so maybe they wanted to keep a log of
> this error every time it happens? I can add the if DEBUG_MODE statement if
> you think it shouldn't be always stored. Let me know.
>
> 55-57 was junk, I got rid of it.
>

Apparently we are not talking about the same line numbers. I mean the ones
in the diff file.
index = 0

   and

box_name = "essay.q"+str(index)
syslog('info', "Box name: %s", box_name)
index = index + 1

but it looks like this is gone now.

>
>
> > Why is replacements['<mm-essay-box>'] always ''? Shouldn't you just get
> > rid of it?
> >
>
> Yes, we're not using the replacements['mm-essay-box'] anymore, this might
> mean some cleaning up is due in all the template related files. I'll leave
> this for the end when I do the cleaning up.
>

OK, I would suggest you put in a comment with at TODO to remind yourself.

>
>
> > In subscribe.py you should make sure that the essay variable that is
> > passed in is the same type (a list?) whether there is just one question
> or
> > many (I can't see where you construct that data structure -- where does
> > that happen?)
> >
> > (in subscribe.py) It seems pretty dangerous to have the question label
> > just be the order in which you process the questions. Python does not
> > guarantee that in a loop that says
> >
> > for foo in foo_list:
> >
> > that you will process each foo in the same order every time. Also, what
> > happens if I reorder these questions (you don't have that functionality
> > yet, but you need it)? Do you want them to have different question
> > numbers? I think you want the question name (like 'talk') here.
> >
>
> Mmm... are you suggesting using the question name as the question ID? That
> would work.
>

Yep, as you understood.

>
>
> >
> > You also seem to have hard coded the version to 1. Why is that?
>
>
> > In DlistUtils.py, the FormQuestion class, why are you putting together
> > that command statement, that seems just to put something in the info log,
> > when your next statement does it more directly? That confused me for
> quite
> > a while.
> >
>
> I know, it confused me too, but it's what every other class does! So I
> thought it was something you guys had agreed on?
>

Nope, I think that when Malveeka did the STORM code, this was just how she
set up her debug statements. We weren't doing code reviews that summer...

Feel free to ask when things...

Read more...

Revision history for this message
Robin J (robin-jeffries) wrote :
Download full text (8.0 KiB)

On Fri, Jul 27, 2012 at 11:16 AM, Ana Cutillas <email address hidden> wrote:

> >
> >
> > In subscribe.py you should make sure that the essay variable that is
> > passed in is the same type (a list?) whether there is just one question
> or
> > many (I can't see where you construct that data structure -- where does
> > that happen?)
> > (in subscribe.py) It seems pretty dangerous to have the question label
> > just be the order in which you process the questions. Python does not
> > guarantee that in a loop that says
> > for foo in foo_list:
> > that you will process each foo in the same order every time. Also, what
> > happens if I reorder these questions (you don't have that functionality
> > yet, but you need it)? Do you want them to have different question
> > numbers? I think you want the question name (like 'talk') here.
> >
> >
> Mmm... are you suggesting using the question name as the question ID? That
> > would work.
>
>
> Ok, I remember now what the problem was with this.
>
> There are two ways I could go about naming the fields in the form.
>
> 1. I could give them the questions names, i.e. woman, talk, etc. That would
> go perfect when writing to the database because I could use that word as
> the ID. BUT, if I do this, when I have to retrieve the fields I don't know
> how many of them there are, or how to retrieve them all. I don't know if
> there's anyway of changing the structure that Cgi uses to send the content
> of the form, or how to add info to this structure.
>

If I'm understanding this right, when you retrieve the fields you want to
do something like

SELECT * from essay_table WHERE email_id = 'xxx' (or whatever key you have
for that person)

Then you have the full set. Again, you need to think about what you are
going to show to the admin, but I imagine a table whose rows are people who
have filled out subscription, and the columns are email, name, woman?,
agree to rules?, how woman in computing, (and then there are some radio
buttons about what to do with each row). You have both the names for the
columns and the values for each cell in that set of things you retrieved.

Go back to the list that I made for you on abiwt.org and subscribe some
more people, so you can see what things look like when an admin has to
approve them. You just need to be able to line up the content into the
right columns (which gets a bit tricky when a column is added, but other
than that, it should be OK -- and I think that you need to do separate
tables for people who have different questions, which might be where the
versioning comes in -- it may not have to do with an individual question
but have to do with the set of questions changing)

>
> 2. I could give them all the same name: essay. This is what I'm doing now.
> But then, you said that the for loop doesn't guarantee that I'll be going
> through the questions always in the same order, and I can't store the
> question name because I don't have it - cgi doesn't send it, it only sends
> the content of the fields. Well, it sends the name of the checkboxes (It
> doesn't send true or false, it either sends woman, or it doesn't send
> anything)
>

So definitely you can't do it that way,...

Read more...

Revision history for this message
Ana Cutillas (acoconut) wrote :
Download full text (6.1 KiB)

On Sat, Jul 28, 2012 at 6:13 AM, Robin J <email address hidden> wrote:

> On Fri, Jul 27, 2012 at 10:43 AM, Ana Cutillas <email address hidden>
> wrote:
>
> > On Fri, Jul 27, 2012 at 6:47 AM, Robin J <email address hidden> wrote:
> >
> > > Review: Needs Fixing
> > >
> > > I would move the comment "added to support subscribe essays" up to the
> if
> > > statement, as right now it looks like just that one line was added for
> > the
> > > essays.
> > >
> >
> > OK, done.
> >
> > >
> > > I would also suggest that you mark lines that are just for your
> debugging
> > > with a comment like "debugging" so that a) I can tell that's what they
> > are,
> > > and b) you can find them to remove them later. I assume lines 53,
> 55-57
> > > are debugging statements?
> > >
> >
> > Line 53 is not mine and it looks to me that when somebody is logging
> > through syslog for debugging, they write to the info file, in this line
> > they're writing to the error log, so maybe they wanted to keep a log of
> > this error every time it happens? I can add the if DEBUG_MODE statement
> if
> > you think it shouldn't be always stored. Let me know.
> >
> > 55-57 was junk, I got rid of it.
> >
>
> Apparently we are not talking about the same line numbers. I mean the ones
> in the diff file.
> index = 0
>
> and
>
> box_name = "essay.q"+str(index)
> syslog('info', "Box name: %s", box_name)
> index = index + 1
>
> but it looks like this is gone now.
>
> Yes, I cleaned that up.

> >
> >
> > > Why is replacements['<mm-essay-box>'] always ''? Shouldn't you just
> get
> > > rid of it?
> > >
> >
> > Yes, we're not using the replacements['mm-essay-box'] anymore, this might
> > mean some cleaning up is due in all the template related files. I'll
> leave
> > this for the end when I do the cleaning up.
> >
>
> OK, I would suggest you put in a comment with at TODO to remind yourself.
>
>
> >
> >
> > > In subscribe.py you should make sure that the essay variable that is
> > > passed in is the same type (a list?) whether there is just one question
> > or
> > > many (I can't see where you construct that data structure -- where does
> > > that happen?)
> > >
> > > (in subscribe.py) It seems pretty dangerous to have the question label
> > > just be the order in which you process the questions. Python does not
> > > guarantee that in a loop that says
> > >
> > > for foo in foo_list:
> > >
> > > that you will process each foo in the same order every time. Also,
> what
> > > happens if I reorder these questions (you don't have that functionality
> > > yet, but you need it)? Do you want them to have different question
> > > numbers? I think you want the question name (like 'talk') here.
> > >
> >
> > Mmm... are you suggesting using the question name as the question ID?
> That
> > would work.
> >
>
> Yep, as you understood.
>
> >
> >
> > >
> > > You also seem to have hard coded the version to 1. Why is that?
> >
> >
> > > In DlistUtils.py, the FormQuestion class, why are you putting together
> > > that command statement, that seems just to put something in the info
> log,
> > > when your next statement does it more directly? That confused me for
> > quite
> > > a while.
> > >
> >
> > I k...

Read more...

Revision history for this message
Ana Cutillas (acoconut) wrote :
Download full text (9.0 KiB)

On Sat, Jul 28, 2012 at 6:25 AM, Robin J <email address hidden> wrote:

> On Fri, Jul 27, 2012 at 11:16 AM, Ana Cutillas <email address hidden>
> wrote:
>
> > >
> > >
> > > In subscribe.py you should make sure that the essay variable that is
> > > passed in is the same type (a list?) whether there is just one question
> > or
> > > many (I can't see where you construct that data structure -- where does
> > > that happen?)
> > > (in subscribe.py) It seems pretty dangerous to have the question label
> > > just be the order in which you process the questions. Python does not
> > > guarantee that in a loop that says
> > > for foo in foo_list:
> > > that you will process each foo in the same order every time. Also,
> what
> > > happens if I reorder these questions (you don't have that functionality
> > > yet, but you need it)? Do you want them to have different question
> > > numbers? I think you want the question name (like 'talk') here.
> > >
> > >
> > Mmm... are you suggesting using the question name as the question ID?
> That
> > > would work.
> >
> >
> > Ok, I remember now what the problem was with this.
> >
> > There are two ways I could go about naming the fields in the form.
> >
> > 1. I could give them the questions names, i.e. woman, talk, etc. That
> would
> > go perfect when writing to the database because I could use that word as
> > the ID. BUT, if I do this, when I have to retrieve the fields I don't
> know
> > how many of them there are, or how to retrieve them all. I don't know if
> > there's anyway of changing the structure that Cgi uses to send the
> content
> > of the form, or how to add info to this structure.
> >
>
> If I'm understanding this right, when you retrieve the fields you want to
> do something like
>
> SELECT * from essay_table WHERE email_id = 'xxx' (or whatever key you have
> for that person)
>
> Then you have the full set. Again, you need to think about what you are
> going to show to the admin, but I imagine a table whose rows are people who
> have filled out subscription, and the columns are email, name, woman?,
> agree to rules?, how woman in computing, (and then there are some radio
> buttons about what to do with each row). You have both the names for the
> columns and the values for each cell in that set of things you retrieved.
>

So we basically want something like what mailman has in
/mailman/admin/listname/members but for pending users? Or do we want to add
columns to that table?

>
> Go back to the list that I made for you on abiwt.org and subscribe some
> more people, so you can see what things look like when an admin has to
> approve them. You just need to be able to line up the content into the
> right columns (which gets a bit tricky when a column is added, but other
> than that, it should be OK -- and I think that you need to do separate
> tables for people who have different questions, which might be where the
> versioning comes in -- it may not have to do with an individual question
> but have to do with the set of questions changing)
>
> I had no idea you had made a list for me. I'm testing everything on my
local machine. Should I use abiwt? And if so, how do I access it?

> >
> > 2. I co...

Read more...

lp:~acoconut/systers/flexible_essays updated
91. By Ana Cutillas <email address hidden>

Cleaned up.

Revision history for this message
Robin J (robin-jeffries) wrote :

On Sat, Jul 28, 2012 at 7:25 AM, Ana Cutillas <email address hidden> wrote:

>
> >
> > formQuestionID =
> > self.store.find(FormQuestion).max(FormQuestion.form_question_id)
> >
> >
> I am saving in formQuestionID the return value from storing which is the
> number that has been autoupdated. Does that make sense?
>

Yes, I think my problem was that I wasn't looking at the left side because
of the line break. My bad.

>
> >
> > I was refering to the line in rmlist
> > DlistUtils.remove_dlist(listname)
> > (which, taken with the lines above it, seems to be that you encapsulated
> > those lines into a method, but I didn't see it in the changes to
> > DlistUtils.py
> >
> >
> > I haven't touched rmlist at all. So I don't know how that changed :-/
>

OK, looks like someone else did this, but it's not in the repo. Next year
we will start everyone with a clean slate and eliminate these issues.

lp:~acoconut/systers/flexible_essays updated
92. By Ana Cutillas <email address hidden>

Cleaned up DlistUtils and changed the error message in subscribe. Added
comments.

93. By Ana Cutillas <email address hidden>

Removed the unused function get_answer from DlistUtils.py

94. By Ana Cutillas <email address hidden>

Added changes to show the new essays in the pending subscriptions table.

Handle the possibility of a user trying to subscribe twice before the
subscription is reviewed.

95. By Ana Cutillas <email address hidden>

Added the functionality to check that the answers aren't longer than
what the database can hold.

96. By Ana Cutillas <email address hidden>

Added the error message saying that the user hasn't been subscribe to
the list when a user tries to subscribe with a pending subscription.

97. By Ana Cutillas <email address hidden>

Made the changes suggested by Robin: concerning error messages and
asserting the size of the answers.

Added the code to mark answers as accepted in the database when a user
is accepted.

98. By Ana Cutillas <email address hidden>

Changed the logic in the checking of answers in subscribe.py
Cleaned up DlistUtils.py

99. By Ana Cutillas <email address hidden>

Added support for setting answers to rejected in the database.

Unmerged revisions

99. By Ana Cutillas <email address hidden>

Added support for setting answers to rejected in the database.

98. By Ana Cutillas <email address hidden>

Changed the logic in the checking of answers in subscribe.py
Cleaned up DlistUtils.py

97. By Ana Cutillas <email address hidden>

Made the changes suggested by Robin: concerning error messages and
asserting the size of the answers.

Added the code to mark answers as accepted in the database when a user
is accepted.

96. By Ana Cutillas <email address hidden>

Added the error message saying that the user hasn't been subscribe to
the list when a user tries to subscribe with a pending subscription.

95. By Ana Cutillas <email address hidden>

Added the functionality to check that the answers aren't longer than
what the database can hold.

94. By Ana Cutillas <email address hidden>

Added changes to show the new essays in the pending subscriptions table.

Handle the possibility of a user trying to subscribe twice before the
subscription is reviewed.

93. By Ana Cutillas <email address hidden>

Removed the unused function get_answer from DlistUtils.py

92. By Ana Cutillas <email address hidden>

Cleaned up DlistUtils and changed the error message in subscribe. Added
comments.

91. By Ana Cutillas <email address hidden>

Cleaned up.

90. By Ana Cutillas <email address hidden>

Cleaned up listinfo.py

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Mailman/Cgi/listinfo.py'
--- Mailman/Cgi/listinfo.py 2009-08-14 15:41:17 +0000
+++ Mailman/Cgi/listinfo.py 2012-07-27 22:03:19 +0000
@@ -22,6 +22,7 @@
22import os22import os
23import cgi23import cgi
2424
25from Mailman import DlistUtils
25from Mailman import mm_cfg26from Mailman import mm_cfg
26from Mailman import Utils27from Mailman import Utils
27from Mailman import MailList28from Mailman import MailList
@@ -36,7 +37,6 @@
36i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)37i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)
3738
3839
39
4040
41def main():41def main():
42 parts = Utils.GetPathPieces()42 parts = Utils.GetPathPieces()
43 if not parts:43 if not parts:
@@ -62,7 +62,6 @@
62 list_listinfo(mlist, language)62 list_listinfo(mlist, language)
6363
6464
65
6665
67def listinfo_overview(msg=''):66def listinfo_overview(msg=''):
68 # Present the general listinfo overview67 # Present the general listinfo overview
69 hostname = Utils.get_domain()68 hostname = Utils.get_domain()
@@ -152,7 +151,6 @@
152 print doc.Format()151 print doc.Format()
153152
154153
155
156154
157def list_listinfo(mlist, lang):155def list_listinfo(mlist, lang):
158 # Generate list specific listinfo156 # Generate list specific listinfo
159 doc = HeadlessDocument()157 doc = HeadlessDocument()
@@ -189,10 +187,29 @@
189187
190 # If activated, the content and presence of questions and a field to answer them. Added by Systers.188 # If activated, the content and presence of questions and a field to answer them. Added by Systers.
191 try:189 try:
192 if mlist.essay_enabled:190 if mlist.essay_enabled: # Added to support subscribe essays
193 replacements['<mm-questions>'] = """<TR>191 html_questions = []
194 <TD COLSPAN="3">""" + mlist.questions192 index = 0
195 replacements['<mm-essay-box>'] = TextArea('essay', '', rows=8, cols=60).Format() + """ </TD></TR>"""# Added to support subscribe essays193 for question in mlist.questions:
194 box_name = "essay.q"+str(index)
195 syslog('info', "Box name: %s", box_name)
196 index = index + 1
197 question_name = "'"+question[1]+"'"
198 html_questions.append("""<TR>
199 <TD COLSPAN="3">""" + question[0] + """</TD>""")
200 if (question[2] == 'smallbox'):
201 html_questions.append("""<TD>""" + TextArea(question_name,\
202 '', rows=1, cols=60).Format() + """</TD></TR>""")
203 elif (question[2] == 'largebox'):
204 html_questions.append("""<TD>""" + TextArea(question_name, \
205 '', rows=8, cols=60).Format() + """</TD></TR>""")
206 elif (question[2] == 'checkbox'):
207 #TODO (Ana Cutillas): consider creating a class like TextArea for checkboxes?
208 html_questions.append("""<TD><input type='checkbox' name='""" \
209 + question[1] + """' value =' """\
210 + question[1] + """'></TD></TR>""")
211 replacements['<mm-questions>'] = ''.join(html_questions)
212 replacements['<mm-essay-box>'] = ''
196 else:213 else:
197 replacements['<mm-questions>'] = ''214 replacements['<mm-questions>'] = ''
198 replacements['<mm-essay-box>'] = ''215 replacements['<mm-essay-box>'] = ''
199216
=== modified file 'Mailman/Cgi/subscribe.py'
--- Mailman/Cgi/subscribe.py 2009-08-14 15:41:17 +0000
+++ Mailman/Cgi/subscribe.py 2012-07-27 22:03:19 +0000
@@ -26,6 +26,7 @@
26from Mailman import MailList26from Mailman import MailList
27from Mailman import Errors27from Mailman import Errors
28from Mailman import i18n28from Mailman import i18n
29from Mailman import DlistUtils # to write to the database
29from Mailman import Message30from Mailman import Message
30from Mailman.DlistUserDesc import DlistUserDesc # to support subscribe essays31from Mailman.DlistUserDesc import DlistUserDesc # to support subscribe essays
31from Mailman.htmlformat import *32from Mailman.htmlformat import *
@@ -137,12 +138,25 @@
137138
138 # Added to support mailing lists that require essays to join139 # Added to support mailing lists that require essays to join
139 if mlist.essay_enabled:140 if mlist.essay_enabled:
140 essay = cgidata.getvalue('essay', '')141 # We need to retrieve the questions to be able to
141 if not essay: # Check for empty essays.142 # retrieve the content from cgi.
142 if not error_msg:143 essay = []
143 print_error(mlist, doc)144 for question in mlist.questions:
144 error_msg = True145 answer = cgidata.getvalue(question[1], '')
145 results.append(_('To subscribe to this list, you must answer the questions asked directly above the large text box.'))146 if (answer):
147 # The question has been answered
148 essay.append((question[1], answer, question[5]))
149 else:
150 if (question[2] != 'checkbox'):
151 # If the answer is empty and it's not a checkbox
152 # the user left fields empty
153 if not error_msg:
154 print_error(mlist, doc)
155 error_msg = True
156 results.append(_('To subscribe to this list, you must answer the questions asked directly above the large text box.'))
157 else:
158 # If the answer is an empty checkbox, the user didn't check it
159 essay.append((question[1], 'False', question[5]))
146 else: # has to be here, else error message when calling DlistUserDesc160 else: # has to be here, else error message when calling DlistUserDesc
147 essay = cgidata.getvalue('essay', 'None')161 essay = cgidata.getvalue('essay', 'None')
148 162
@@ -215,6 +229,14 @@
215may have to be first confirmed by you via email, or approved by the list229may have to be first confirmed by you via email, or approved by the list
216moderator. If confirmation is required, you will soon get a confirmation230moderator. If confirmation is required, you will soon get a confirmation
217email which contains further instructions.""")231email which contains further instructions.""")
232 question_index = 0
233 if (isinstance(essay, str)): #There's only one question, so it comes as a string.
234 form = DlistUtils.FormQuestion(mlist)
235 form.recordAnswer(email, question_index, essay, 1)
236 else:
237 for answer in essay:
238 form = DlistUtils.FormQuestion(mlist)
239 form.recordAnswer(email, answer[0], answer[1], answer[2])
218240
219 try:241 try:
220 userdesc = DlistUserDesc(email, fullname, password, digest, lang, essay)242 userdesc = DlistUserDesc(email, fullname, password, digest, lang, essay)
221243
=== modified file 'Mailman/DlistUtils.py'
--- Mailman/DlistUtils.py 2010-01-31 20:29:48 +0000
+++ Mailman/DlistUtils.py 2012-07-27 22:03:19 +0000
@@ -289,6 +289,62 @@
289 self.store.find(Alias,Alias.subscriber_id == obsolete_id).set(subscriber_id = new_id)289 self.store.find(Alias,Alias.subscriber_id == obsolete_id).set(subscriber_id = new_id)
290 self.store.find(Subscriber,Subscriber.subscriber_id == obsolete_id).remove() 290 self.store.find(Subscriber,Subscriber.subscriber_id == obsolete_id).remove()
291291
292class FormQuestion(object):
293 __storm_table__ = "form_question"
294 form_question_id = Int(primary = True,default = AutoReload)
295 content = Unicode()
296 user_email = Unicode()
297 version = Int()
298 question_id = Unicode()
299 status = Unicode()
300
301 def __init__(self,mlist):
302 self.mlist = mlist
303 self.database = getConn(mlist)
304
305 @decfunc
306 def recordAnswer(self, addr, question, answer, version):
307 """Save the answer for a question of the subscribe form, returning its id."""
308 subscriber = Subscriber(self.mlist)
309 userID = addr.decode('utf-8')
310 status = u"pending"
311 question_unicode = question.decode('utf-8')
312 answer_unicode = answer.decode('utf-8')
313
314 command = "form_question = self.store.add(FormQuestion())\nform_question.content = answer_unicode\nform_question.email = userID\nform_question.version = version\nform_question.question_id = question_unicode\nform_question.status = status\n"
315 if DEBUG_MODE:
316 syslog('info', 'DlistUtils:(recordAnswer)executing query:\n%s', command)
317 syslog('info', 'DlistUtils:(recordAnswer) query parameters:\n content:%s\n userid:%s\n version:%s\n question_id:%s\n status:%s\n ', answer_unicode, userID, version, question_unicode, status)
318 #form_question_id has autoreload set, its value will be serially updated in database
319 self.user_email = userID
320 self.content = answer_unicode
321 self.version = version
322 self.question_id = question_unicode
323 self.status = status
324 self.store.add(self)
325 formQuestionID = self.store.find(FormQuestion).max(FormQuestion.form_question_id)
326 if DEBUG_MODE:
327 syslog('info', 'Result of query(formQuestionID) is: %s\n', formQuestionID)
328 return formQuestionID
329
330 @decfunc
331 def get_answer(self, user_email, form_question_id):
332 """Execute a SELECT statement, returning the results as a list."""
333 command = "result = self.store.find(FormQuestion,form_question.user_email == user_email)\nform_question.form_question_id = form_question_id]\n"
334 if DEBUG_MODE:
335 syslog('info', 'DlistUtils(get_answer):Executing query:\n%s', command)
336 result = self.store.find(FormQuestion,FormQuestion.user_email == user_email)
337 syslog('info', "Result %s", result)
338 return result.content
339
340 def acceptAnswer(self, addr):
341 #TODO (Ana Cutillas): Finish this function if we need it.
342 """Sets the status of the answers to accepted"""
343 subscriber = Subscriber(self.mlist)
344 userID = subscriber.getSubscriber_id_raw_or_die(addr)
345# command = "form_question = self.store.
346
347
292class Message(object):348class Message(object):
293 __storm_table__ = "message"349 __storm_table__ = "message"
294 message_id = Int(primary = True,default = AutoReload)350 message_id = Int(primary = True,default = AutoReload)
295351
=== modified file 'bin/rmlist'
--- bin/rmlist 2009-07-31 10:49:01 +0000
+++ bin/rmlist 2012-07-27 22:03:19 +0000
@@ -152,12 +152,7 @@
152152
153 # Remove the database in PostgreSQL if it was a dynamic list. Added by Systers.153 # Remove the database in PostgreSQL if it was a dynamic list. Added by Systers.
154 try:154 try:
155 conn = DlistUtils.getConn(None)155 DlistUtils.remove_dlist(listname)
156 old_iso_lvl = conn.isolation_level
157 conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
158 cursor = conn.cursor()
159 cursor.execute('DROP DATABASE "%s"' % listname)
160 conn.set_isolation_level(old_iso_lvl)
161 except:156 except:
162 syslog('error', 'Tried to remove the database for %s, no such database (ok if it was a non dlist). If it was a dlist, the postgreSQL database for this list needs to be removed manually.' % listname)157 syslog('error', 'Tried to remove the database for %s, no such database (ok if it was a non dlist). If it was a dlist, the postgreSQL database for this list needs to be removed manually.' % listname)
163158

Subscribers

People subscribed via source and target branches