Archive

Tag Archives: django

What is django-userena?

django-userena is a Django application that supplies your Django project with full account management. It’s a fully customizable application that takes care of the signup, activation, messaging and more.

How to install django-userena?
You can install the latest version of django-userena using:
pip install django-userena

Source Code:
https://github.com/bread-and-pepper/django-userena

How to setup django-userena?
Add AUTHETICATION_BACKEND tuple as given below:

AUTHENTICATION_BACKENDS = (
    'userena.backends.UserenaAuthenticationBackend',
    'guardian.backends.ObjectPermissionBackend',
    'django.contrib.auth.backends.ModelBackend',
)

Add userena, gaurdian and easy_thumbnails to your INSTALLED_APPS settings of your project.

The URI’s
Userena has a URLConf that sets all the url’s and views for you. This should be included in your project’s URLConf. For example, if you wants the urls to show up under ‘/accounts/’, add the following under urlpattern in you URLConf.

(r'^accounts/', include('userena.urls')),

Required Settings
1. Django-guardian requires you to set the ANONYMOUS_USER_ID setting.

ANONYMOUS_USER_ID = -1

2. Set AUTH_PROFILE_MODULE point to the model that is your custom made profile.For example: set AUTH_PROFILE_MODULE to the path of MyProfile

from userena.models import UserenaBaseProfile

class MyProfile(UserenaBaseProfile):
    user = models.OneToOneField(User,
                                unique=True,
                                verbose_name=_('user'),
                                related_name='my_profile')
    favourite_snack = models.CharField(_('favourite snack'),
                                       max_length=5)

3. To integrate with Django, you need to alter three settings to reflect in you URI.
For example, if your userena lives under ‘/accounts/’

LOGIN_REDIRECT_URL = '/accounts/%(username)s/'
LOGIN_URL = '/accounts/signin/'
LOGOUT_URL = '/accounts/signout/'

References:django-userena documentation

Hi there! It’s been a long time since my last blog post. In the break, I was facing my semester exams, and I felt better stay away from my laptop rather than books. Though other reason of not remaining online was my Nokia C5 mobile got pick-pocketed 😦 and I didn’t have any mode to remain online. After the my exam ended, I again bought the same mobile and started on working on transifex. I had already written some code before the exam so that anonymous users can access to the files through web-interface. But, mpessas and rtnpro suggested me to work on allowing anonymous access through the API and write some tests for the same.

So, after the exams this was my first task in hand, I went through the Transifex APIv2 docs and made some changes in the code to get the job done. I also wrote the test with the help of @rtnpro. I was also facing problem with the notification settings bar in the profile settings page. Though the ENABLE_NOTICES settings was set to True. The notification settings bar was not showing up. After the studying the code for the templatetag settings, I found out that the templatetag itself was the cause for the issue. Moving the templatetag inside the content_main block in templates/userena/base_userena.html solved the issue.

In the mean time, I read about the revised version of the Microsoft Translation API. Earlier, the Bing AppID was enough to get the work done. But now, the Bing AppID is deprecated and is no longer supported. To use the Microsoft Translator API, one has to obtain an access token using Client ID and Client Secret obtained after registering an application at Azure DataMarket and use it for the calls to the Microsoft Translator API. The process of obtaining the access token can be seen here . The Microsoft Translator API is well documented and it help me a lot. Currently, I am working on implementing the new Microsoft Translator API in transifex.

I am also currently working on the feature approved by jkal to we allow users to set their username after the first login through the social method in transifex (Facebook, Google, Twitter and LinkedIn).

For some time now, I started working up on Dorrie. Dorrie is a web application which enables users to build a Fedora/Spin.It is a Free Software licensed under the GNU Affero General Public License v3 or later and written using Django/Python.

After successfully downloading and deploying Dorrie from GitHub, I found out that it was showing an error “invalid arguments to setopt” in the /basic/ page. So after googling for few minutes I came to know the error was arising because setopt was receving uni-code as the argument in place of string So, after the modification of the code, I sent the patch upstream. Later, Shrink, rtnpro and I were discussing on Dorrie so rtnpro came up with the idea of making the code modular and dividing the codes in files based on type of settings. He also told of introducing django-addons into Dorrie as it adding a true plug-n-play functionality to our own Django applications and he assigned me the job. Since, it had been quite sometime I had worked on Git, I had forgotten some of the commands so I had to google the commands again and write out the patch. I sent out the patch upstream the following day. Here is my Dorrie clone on GitHub.

Last week, I started working on the ticket #789 which reported that there should be support for the xliff files with .xml extension. As it was an easy patch with few edits in the configuration file and tests I submitted the patch to upstream for review and they accepted it. 🙂
After that rtnpro directed /me to work on the ticket #673 which reported that there should be a RSS Feed for the project timeline. As I had already worked with RSS Feed in ASKBOT so I had a prior knowledge about the topic. But I went through the topic once again more deeply and got to a lot more things. It took sometime due the festive season in between but submitted the patch for review as soon as possible and got it accepted.
After that I started off ticket #578 but could not complete it as I found that there was a bug in the /project/add/ page which raised the NoReverseMatch exception so I reported this to rtnpro and started working on it and found some more bugs and a typo and finally resolved it altogether and submitted the patch. I also sent a patch regarding a bug in the Manage tab which was losing it’s selection after the sub menu item was pressed.

For some time now, after my exams got over I started hanging going through the source code of Transifex. After some time, I contacted rtnpro and he directed me to work on the ticket #808.
The ticket #808 reported that searching should be made possible not only in the source text but also in the translations.So, I had to go through Complex lookups with Q objects in order to write the patch. I submitted patch upstream for review and got it accepted.:)

%d bloggers like this: