Kép a férfiakról
Néhány haveromat beválogatták egy filmforgatásra, ahol egy férfivá-avatást jásztanak majd el. Ehhez mindannyiuk haját kopaszra borotválják. Erről már a válogatáson is tudtak. Íme egy jelenet a borotválásból:
continue readingNéhány haveromat beválogatták egy filmforgatásra, ahol egy férfivá-avatást jásztanak majd el. Ehhez mindannyiuk haját kopaszra borotválják. Erről már a válogatáson is tudtak. Íme egy jelenet a borotválásból:
continue readingIn the past days there was a quite nice discussion on Editors of choice on the list, and this encouraged me to give Vim another try. This time, it seems to be rather fruitful!
continue readingDuring my trip in Bulgaria starting in a couple of weeks we will take part in a fund-raising mountain hiking for the Karin Dom foundation. As besides our participation we would like to help them financially as well we decided to put together a small website where friends and colleagues might sponsor us, so we can transfer their donations to Karin Dom.
To accomplish this task, I wrote a small django application, django-donation. This application let’s you easily receive donations on your website, and tries to show some relevant information about your sponsors, like to total amount collected. Moreover, depending on the sponsors’ wishes you might show their name and donation as well.
During this work I have learned several things:
Circumventing PayPal’s security checks is a breeze (but still annoying to have to) For the donation I thought I will need a Business type account. Probably I was wrong as a Premium account would suffice, but when I realised this my account was already changed into a Business account, and PayPal was asking for all kind of weird papers. For some reason, they were not very eager to change back my account type, thus I went on and asked all kind of recommendations from Karin Dom, and explained to PayPal that actually I am not affiliated to them, we are just collecting funds for them. Finally they allowed my account, and now I can collect the donations. The twist in this story is that Karin Dom struggles getting the Business status, thus despite the PayPal button on their site, you can donate to them only via direct transfers.
Use the identifier if you can Unfortunately django-donation still has some flaws. The main problem is that I am not saving the unique identifiers of every transaction, and several of our donors were registered twice or even more times. I will fix this once I have some more time (might be tonight?), or feel free to do it, if you have some free time. :)
Finally, you can check out our Karin Dom sponsorship site here.
The past week as a sub-project of django-conference, I’ve built a really simple and hopefully useful application to make csv exporting extremely easy.
It uses python’s csv library, and can be set up for example with the following code in your urlconf:
from export_csv.views import export_csv
export_attendees = {
'queryset': Attendee.objects.all(),
'filter_by': 'conference__pk',
'export_data': {'is_presenter': 'Presents',
'user.get_full_name': 'Attendee',
'conference': 'Conference',
'user.get_profile.affiliation': 'Affiliation',
},
'require_permission': 'conference.delete_attendee',
}
urlpatterns = patterns('',
url(r'^export/attendees/(?P<object_id>\d+)/$', export_csv,
export_attendees, name='export_attendees'),
)
This code was taken from an ongoing project to build a conference administering application for django (and for the Hungarian Economists Association).
Basically, the above setting will take a queryset by default that can be further filtered to get the data to be exported, and the export_data dictionary describes the columns to be exported. As the example shows, the columns can be either callable or simple properties, and will be evaluated from the instances of the exported queryset, like attendee_instance.is_presenter(). While column headers are given as the values for export_data.
The view code is really simple, the only tricky part was to construct the callable/non-callable object paths described in export_data, this is done by the following method
def get_attr(object, attrs=None):
if attrs == None or attrs == []:
return object
current = attrs.pop(0)
try:
return get_attr(callable(getattr(object, current)) and
getattr(object, current)() or
getattr(object, current), attrs)
except ObjectDoesNotExist:
return not_available
If you would like to add some extra functionality, like date based exporting, or just would like to play with the code, go and grab it from launchpad:
I’m continuously trying to get used to test driven development, as I agree with its many advantages cited around the web. Still, I often find it hard to come up with a necessary (and hopefully sufficient) list of tests. Moreover, as I often code for fun only, I don’t pay much attention to the question. This has changed now as I got a paying project. Here are my first insights, I hope it will help other django enthusiasts as well. :)
The bottom line is test every method you write, including output variables and inside logic. Moreover, write tests that pass as they mimick normal usage, and then start to think about tests that fail if someone tries abnormal usage (like setting a start date after an end date).
continue reading