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
1=== modified file 'Mailman/Cgi/listinfo.py'
2--- Mailman/Cgi/listinfo.py 2009-08-14 15:41:17 +0000
3+++ Mailman/Cgi/listinfo.py 2012-07-27 22:03:19 +0000
4@@ -22,6 +22,7 @@
5 import os
6 import cgi
7
8+from Mailman import DlistUtils
9 from Mailman import mm_cfg
10 from Mailman import Utils
11 from Mailman import MailList
12@@ -36,7 +37,6 @@
13 i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)
14
15
16-
17
18 def main():
19 parts = Utils.GetPathPieces()
20 if not parts:
21@@ -62,7 +62,6 @@
22 list_listinfo(mlist, language)
23
24
25-
26
27 def listinfo_overview(msg=''):
28 # Present the general listinfo overview
29 hostname = Utils.get_domain()
30@@ -152,7 +151,6 @@
31 print doc.Format()
32
33
34-
35
36 def list_listinfo(mlist, lang):
37 # Generate list specific listinfo
38 doc = HeadlessDocument()
39@@ -189,10 +187,29 @@
40
41 # If activated, the content and presence of questions and a field to answer them. Added by Systers.
42 try:
43- if mlist.essay_enabled:
44- replacements['<mm-questions>'] = """<TR>
45- <TD COLSPAN="3">""" + mlist.questions
46- replacements['<mm-essay-box>'] = TextArea('essay', '', rows=8, cols=60).Format() + """ </TD></TR>"""# Added to support subscribe essays
47+ if mlist.essay_enabled: # Added to support subscribe essays
48+ html_questions = []
49+ index = 0
50+ for question in mlist.questions:
51+ box_name = "essay.q"+str(index)
52+ syslog('info', "Box name: %s", box_name)
53+ index = index + 1
54+ question_name = "'"+question[1]+"'"
55+ html_questions.append("""<TR>
56+ <TD COLSPAN="3">""" + question[0] + """</TD>""")
57+ if (question[2] == 'smallbox'):
58+ html_questions.append("""<TD>""" + TextArea(question_name,\
59+ '', rows=1, cols=60).Format() + """</TD></TR>""")
60+ elif (question[2] == 'largebox'):
61+ html_questions.append("""<TD>""" + TextArea(question_name, \
62+ '', rows=8, cols=60).Format() + """</TD></TR>""")
63+ elif (question[2] == 'checkbox'):
64+ #TODO (Ana Cutillas): consider creating a class like TextArea for checkboxes?
65+ html_questions.append("""<TD><input type='checkbox' name='""" \
66+ + question[1] + """' value =' """\
67+ + question[1] + """'></TD></TR>""")
68+ replacements['<mm-questions>'] = ''.join(html_questions)
69+ replacements['<mm-essay-box>'] = ''
70 else:
71 replacements['<mm-questions>'] = ''
72 replacements['<mm-essay-box>'] = ''
73
74=== modified file 'Mailman/Cgi/subscribe.py'
75--- Mailman/Cgi/subscribe.py 2009-08-14 15:41:17 +0000
76+++ Mailman/Cgi/subscribe.py 2012-07-27 22:03:19 +0000
77@@ -26,6 +26,7 @@
78 from Mailman import MailList
79 from Mailman import Errors
80 from Mailman import i18n
81+from Mailman import DlistUtils # to write to the database
82 from Mailman import Message
83 from Mailman.DlistUserDesc import DlistUserDesc # to support subscribe essays
84 from Mailman.htmlformat import *
85@@ -137,12 +138,25 @@
86
87 # Added to support mailing lists that require essays to join
88 if mlist.essay_enabled:
89- essay = cgidata.getvalue('essay', '')
90- if not essay: # Check for empty essays.
91- if not error_msg:
92- print_error(mlist, doc)
93- error_msg = True
94- results.append(_('To subscribe to this list, you must answer the questions asked directly above the large text box.'))
95+ # We need to retrieve the questions to be able to
96+ # retrieve the content from cgi.
97+ essay = []
98+ for question in mlist.questions:
99+ answer = cgidata.getvalue(question[1], '')
100+ if (answer):
101+ # The question has been answered
102+ essay.append((question[1], answer, question[5]))
103+ else:
104+ if (question[2] != 'checkbox'):
105+ # If the answer is empty and it's not a checkbox
106+ # the user left fields empty
107+ if not error_msg:
108+ print_error(mlist, doc)
109+ error_msg = True
110+ results.append(_('To subscribe to this list, you must answer the questions asked directly above the large text box.'))
111+ else:
112+ # If the answer is an empty checkbox, the user didn't check it
113+ essay.append((question[1], 'False', question[5]))
114 else: # has to be here, else error message when calling DlistUserDesc
115 essay = cgidata.getvalue('essay', 'None')
116
117@@ -215,6 +229,14 @@
118 may have to be first confirmed by you via email, or approved by the list
119 moderator. If confirmation is required, you will soon get a confirmation
120 email which contains further instructions.""")
121+ question_index = 0
122+ if (isinstance(essay, str)): #There's only one question, so it comes as a string.
123+ form = DlistUtils.FormQuestion(mlist)
124+ form.recordAnswer(email, question_index, essay, 1)
125+ else:
126+ for answer in essay:
127+ form = DlistUtils.FormQuestion(mlist)
128+ form.recordAnswer(email, answer[0], answer[1], answer[2])
129
130 try:
131 userdesc = DlistUserDesc(email, fullname, password, digest, lang, essay)
132
133=== modified file 'Mailman/DlistUtils.py'
134--- Mailman/DlistUtils.py 2010-01-31 20:29:48 +0000
135+++ Mailman/DlistUtils.py 2012-07-27 22:03:19 +0000
136@@ -289,6 +289,62 @@
137 self.store.find(Alias,Alias.subscriber_id == obsolete_id).set(subscriber_id = new_id)
138 self.store.find(Subscriber,Subscriber.subscriber_id == obsolete_id).remove()
139
140+class FormQuestion(object):
141+ __storm_table__ = "form_question"
142+ form_question_id = Int(primary = True,default = AutoReload)
143+ content = Unicode()
144+ user_email = Unicode()
145+ version = Int()
146+ question_id = Unicode()
147+ status = Unicode()
148+
149+ def __init__(self,mlist):
150+ self.mlist = mlist
151+ self.database = getConn(mlist)
152+
153+ @decfunc
154+ def recordAnswer(self, addr, question, answer, version):
155+ """Save the answer for a question of the subscribe form, returning its id."""
156+ subscriber = Subscriber(self.mlist)
157+ userID = addr.decode('utf-8')
158+ status = u"pending"
159+ question_unicode = question.decode('utf-8')
160+ answer_unicode = answer.decode('utf-8')
161+
162+ 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"
163+ if DEBUG_MODE:
164+ syslog('info', 'DlistUtils:(recordAnswer)executing query:\n%s', command)
165+ 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)
166+ #form_question_id has autoreload set, its value will be serially updated in database
167+ self.user_email = userID
168+ self.content = answer_unicode
169+ self.version = version
170+ self.question_id = question_unicode
171+ self.status = status
172+ self.store.add(self)
173+ formQuestionID = self.store.find(FormQuestion).max(FormQuestion.form_question_id)
174+ if DEBUG_MODE:
175+ syslog('info', 'Result of query(formQuestionID) is: %s\n', formQuestionID)
176+ return formQuestionID
177+
178+ @decfunc
179+ def get_answer(self, user_email, form_question_id):
180+ """Execute a SELECT statement, returning the results as a list."""
181+ command = "result = self.store.find(FormQuestion,form_question.user_email == user_email)\nform_question.form_question_id = form_question_id]\n"
182+ if DEBUG_MODE:
183+ syslog('info', 'DlistUtils(get_answer):Executing query:\n%s', command)
184+ result = self.store.find(FormQuestion,FormQuestion.user_email == user_email)
185+ syslog('info', "Result %s", result)
186+ return result.content
187+
188+ def acceptAnswer(self, addr):
189+ #TODO (Ana Cutillas): Finish this function if we need it.
190+ """Sets the status of the answers to accepted"""
191+ subscriber = Subscriber(self.mlist)
192+ userID = subscriber.getSubscriber_id_raw_or_die(addr)
193+# command = "form_question = self.store.
194+
195+
196 class Message(object):
197 __storm_table__ = "message"
198 message_id = Int(primary = True,default = AutoReload)
199
200=== modified file 'bin/rmlist'
201--- bin/rmlist 2009-07-31 10:49:01 +0000
202+++ bin/rmlist 2012-07-27 22:03:19 +0000
203@@ -152,12 +152,7 @@
204
205 # Remove the database in PostgreSQL if it was a dynamic list. Added by Systers.
206 try:
207- conn = DlistUtils.getConn(None)
208- old_iso_lvl = conn.isolation_level
209- conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
210- cursor = conn.cursor()
211- cursor.execute('DROP DATABASE "%s"' % listname)
212- conn.set_isolation_level(old_iso_lvl)
213+ DlistUtils.remove_dlist(listname)
214 except:
215 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)
216

Subscribers

People subscribed via source and target branches