ericmckean / google-highly-open-participation-plone

Automatically exported from code.google.com/p/google-highly-open-participation-plone
0 stars 0 forks source link

Create a Plone 3 portlet that shows a pre-configured "donate with PayPal" button #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using the new portlets infrastructure in Plone 3, create a portlet that allows 
the user to enter some 
basic parameters (such as a PayPal account) in order to render a "donate" 
button.

Original issue reported on code.google.com by optil...@gmail.com on 19 Nov 2007 at 11:41

GoogleCodeExporter commented 9 years ago

Original comment by l...@gmail.com on 27 Nov 2007 at 7:11

GoogleCodeExporter commented 9 years ago
I claim this task.

Original comment by qpfif...@gmail.com on 29 Nov 2007 at 6:35

GoogleCodeExporter commented 9 years ago
I claim this Task

Original comment by qpfif...@gmail.com on 29 Nov 2007 at 5:10

GoogleCodeExporter commented 9 years ago
Thanks gpfiffer - looking forward to your entry in 3 days' time!

Original comment by optil...@gmail.com on 29 Nov 2007 at 11:07

GoogleCodeExporter commented 9 years ago

Original comment by optil...@gmail.com on 29 Nov 2007 at 11:14

GoogleCodeExporter commented 9 years ago
Hi gpfiffer - can you give us an update on your progress? Your time limit is 
nearly up.

We can give you a further two days, but then we have to re-open the task 
according to the contest rules.

Original comment by optil...@gmail.com on 2 Dec 2007 at 8:33

GoogleCodeExporter commented 9 years ago
A two-day extension might be needed. I was working on a 2.5 style portlet before
realizing Plone 3 was completely different, so Im working on installing 
ZopeSkel to
get a basic outline of what I should be doing.

Original comment by qpfif...@gmail.com on 2 Dec 2007 at 8:48

GoogleCodeExporter commented 9 years ago
That's fair enough. :) Thanks for getting back to us so quickly. Let us know 
how you get on. If you need help, 
the best place to ask is the plone-user mailing list - see 
http://plone.org/support.

Original comment by optil...@gmail.com on 2 Dec 2007 at 8:51

GoogleCodeExporter commented 9 years ago

Original comment by mw4...@googlemail.com on 4 Dec 2007 at 2:02

GoogleCodeExporter commented 9 years ago
Im not going to be able to meet the deadline, sorry guys.

Original comment by qpfif...@gmail.com on 5 Dec 2007 at 6:46

GoogleCodeExporter commented 9 years ago
Sorry to hear it, but that's ok, reopening the task. 

Original comment by mw4...@googlemail.com on 5 Dec 2007 at 9:54

GoogleCodeExporter commented 9 years ago
I claim this Task

Original comment by tungolc...@gmail.com on 3 Jan 2008 at 2:23

GoogleCodeExporter commented 9 years ago
Its yours tungolcild.  We look forward to your submission in 3 days.

Original comment by mw4...@googlemail.com on 3 Jan 2008 at 5:03

GoogleCodeExporter commented 9 years ago
Due to personal reason I have to unclaim this task. But if on a later day is 
open i will continue it. Thanks

Original comment by tungolc...@gmail.com on 4 Jan 2008 at 1:40

GoogleCodeExporter commented 9 years ago

Original comment by mw4...@googlemail.com on 7 Jan 2008 at 3:34

GoogleCodeExporter commented 9 years ago
I claim this Task

Original comment by speedbre...@gmail.com on 19 Jan 2008 at 5:16

GoogleCodeExporter commented 9 years ago
It's yours, have fun!

Original comment by mw4...@googlemail.com on 20 Jan 2008 at 5:07

GoogleCodeExporter commented 9 years ago
This was a pretty fast task for me to finish.  I've tested my portlet in the
following browsers:

   * Firefox 2.0.0.11 (Windows XP)
   * Opera 9.50 beta (Build 9613) (Windows XP)
   * Safari 3.0.4 beta (Windows XP)
   * Internet Explorer 6.0 (Windows XP)

In the portlet, I gave users a dropdown box for selecting an amount.  The 
'Other'
item shows a text box that allows users to select a custom amount.  Since this
happens through Javscript, I made the portlet such that it won't send an invalid
value to PayPal in the case that user has disabled Javascript in their browser.

If you want me to change anything, please let me know!

Original comment by speedbre...@gmail.com on 20 Jan 2008 at 6:09

Attachments:

GoogleCodeExporter commented 9 years ago
I'm getting the following error:

File
"/Users/matthewwilkes/work/plone/projects/ghop/portlet/src/plone.portlet.donatew
ithpaypal/setup.py",
line 7
    description="This is a portlet that shows a "donate with PayPal button".",

Fairly self explanatory, you need to change the description field to not 
include any
quotation marks.

When this is fixed I get:

    *  Module ZPublisher.Publish, line 119, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 42, in call_object
    * Module plone.app.portlets.browser.formhelper, line 53, in __call__
    * Module zope.formlib.form, line 769, in __call__
    * Module Products.Five.formlib.formbase, line 55, in update
    * Module zope.formlib.form, line 750, in update
    * Module zope.formlib.form, line 594, in success
    * Module plone.app.portlets.browser.formhelper, line 70, in handle_save_action
    * Module zope.formlib.form, line 866, in createAndAdd
    * Module plone.portlet.donatewithpaypal.donatewithpaypal, line 79, in create

TypeError: __init__() got an unexpected keyword argument 'account'

when creating a portlet.

In addition, you might like to change the name to collective.portlet.paypal and 
the
Generic Setup profile name to PayPal portlet.  Neither are very important, it'd 
just
fit in better with the naming conventions that are starting to evolve.  (The 
current
ones are named either after the collective or a company name)

Original comment by mw4...@googlemail.com on 20 Jan 2008 at 6:34

GoogleCodeExporter commented 9 years ago
This probably didn't work with easy_install/setuptools because I didn't test for
that.  I normally install packages into the unified installer manually.  

I've just figured out how to get buildout to run on Ubuntu so I can test with
setuptools/easy_install.  I couldn't get the Plone Buildout tutorial
(http://plone.org/documentation/tutorial/buildout/tutorial-all-pages) 
instructions to
work on Ubuntu without some extra steps.

Original comment by speedbre...@gmail.com on 20 Jan 2008 at 10:29

GoogleCodeExporter commented 9 years ago
Here's a fixed version! I tested it in my new Ubuntu-based buildout.

If you encounter any errors or want me to fix anything, feel free to ask!

Original comment by speedbre...@gmail.com on 20 Jan 2008 at 10:51

Attachments:

GoogleCodeExporter commented 9 years ago
Still not quite:

Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module plone.app.portlets.browser.formhelper, line 53, in __call__
  Module zope.formlib.form, line 769, in __call__
  Module Products.Five.formlib.formbase, line 55, in update
  Module zope.formlib.form, line 750, in update
  Module zope.formlib.form, line 594, in success
  Module plone.app.portlets.browser.formhelper, line 70, in handle_save_action
  Module zope.formlib.form, line 866, in createAndAdd
  Module collective.portlet.paypal.paypalportlet, line 82, in create
TypeError: __init__() got an unexpected keyword argument 'some_field'

Probably because you've got a duplicate __init__:

    # TODO: Add keyword parameters for configurable parameters here
    def __init__(self, some_field=u""):
        self.some_field = some_field

    def __init__(self):
        pass

Also, could you add a configuration option to choose the currency used?  This 
only
needs to be a selection between USD/EUR/GBP (make things a little nicer for us
Europeans) but you can go further if you like and allow people to enter a 
currency
code.  Taking that further, you could give the option to configure the available
donation amounts.  (Just a thought!)

Original comment by mw4...@googlemail.com on 20 Jan 2008 at 11:35

GoogleCodeExporter commented 9 years ago
I just fixed the duplicate __init__.  I also added a currency code box that 
allows
you to add any currency code that you want.  PayPal deals with all of the 
currency
code information automatically.

For the optional currency amounts, I plan to allow the user to change the 
donation
amounts with a comma-separated list (e.g. 10, 20, 30, other) like with tags on a
blog.  Possible non-decimal valies (like "other") would be listed above the 
text box.
What do you think of this idea?

Original comment by speedbre...@gmail.com on 21 Jan 2008 at 12:43

GoogleCodeExporter commented 9 years ago
Currency code box sounds good.

For the amounts there is a special type of field for lists, the Tuple field.

eg:

schema.Tuple(title=u'My Field',
    description=u'A field',
    value_type=schema.Float(title=u"Amount"))

Original comment by mw4...@googlemail.com on 21 Jan 2008 at 12:55

GoogleCodeExporter commented 9 years ago
I just added the Tuple field.

Do you think that it would be a good idea to add a way to change the header and 
put
text under the header, but before the dropdown box and donation button?  I've 
seen
this on a few websites before.

Original comment by speedbre...@gmail.com on 21 Jan 2008 at 1:35

GoogleCodeExporter commented 9 years ago
Perhaps, but we don't have access to a rich text field at the moment so it 
would be
quite limited.  WYSIWYG editing in z3 schemata is due in Plone 3.1, I think.  
It's
your call!

Original comment by mw4...@googlemail.com on 21 Jan 2008 at 2:32

GoogleCodeExporter commented 9 years ago
Thanks for your input!  I decided to have a user-modifiable portlet title, but 
not
the text under the header.  In the options area, I added a checkbox to 
enable/disable
the "other" option in the dropdown.

I've attached the latest version of the portlet to this comment.  Let me know 
if you
want me to make more changes or if it outputs an error.

Original comment by speedbre...@gmail.com on 21 Jan 2008 at 2:53

Attachments:

GoogleCodeExporter commented 9 years ago
So close on this one.  The show other option assumes 5 options are available, 
perhaps
it would be better doing it without javascript?  This is excellent work, I'll be
using this on an upcoming project myself.

Original comment by mw4...@googlemail.com on 21 Jan 2008 at 1:27

GoogleCodeExporter commented 9 years ago
You're right, it would be far  easier to insert the "Other" option through:

    tal:condition="view/data/donation_other"

Thanks for your input!

Original comment by speedbre...@gmail.com on 21 Jan 2008 at 4:26

GoogleCodeExporter commented 9 years ago
I ended up using pure javascript again.  Even though it was more complex to add 
the
"other" option, it made it easier to provide a fall-back position in the case 
that
the user has not enabled javascript.

I also added validation to the textbox to prevent paypal from getting invalid
information.

Original comment by speedbre...@gmail.com on 21 Jan 2008 at 5:04

GoogleCodeExporter commented 9 years ago
Ok, whatever works for you!

Original comment by mw4...@googlemail.com on 21 Jan 2008 at 5:06

GoogleCodeExporter commented 9 years ago
Here's the latest version of the portlet!  If you want me to change anything, 
feel
free to ask!

This version has the following changes:

    * Textbox validation
    * Fixed "other" option

Original comment by speedbre...@gmail.com on 21 Jan 2008 at 5:07

GoogleCodeExporter commented 9 years ago
Here's the file so that you can test it!

Original comment by speedbre...@gmail.com on 21 Jan 2008 at 5:19

Attachments:

GoogleCodeExporter commented 9 years ago
Very nice, well done!  I've closed the task now.

Original comment by mw4...@googlemail.com on 21 Jan 2008 at 6:08