2 problems with registration - django

I use the obvious powerful registration 0.8 alpha version. I do have to questions.
1.) I want to add the checkbox RegistrationTermsOfService at the registration form html file. I just don't know how to do it. Please don't give me an link on uebernstorm docs. Just tell me please how to do it. I have read and tried a lot and it actually doesn't work. I am dispairing!
2.) The activation email is send with the activation key. When I click on activation the account is getting activated in the database but the template says something different. It says:"Sorry, it didn't work. Either..."
I use the standard activate.html below:
{% extends "base.html" %}
{% block title %}Account activated{% endblock %}
{% block content %}
Account activated
{% load humanize %}
{% if account %}
Thanks for signing up! Now you can "href"
{% else %}
Sorry, it didn't work. Either your activation link was incorrect, or
the activation key for your account has expired; activation keys are
only valid for {{ expiration_days|apnumber }} days after
registration.
{% endif %}
{% endblock %}
PLEASE, PLEASE help me!!! I am dispairing!!!
Craphunter

For 1) you need to use a different form. Look in registration.forms for the one you need and pass it as an additional argument in the backend's urls.py
For 2) we'll need more info - is the URL correct? Is there a RegistrationProfile object created for the user account in question? What is the value of the key?

Related

Django template fragment caching not working the way it is supposed to

Referring to following documentation, I am trying this
https://docs.djangoproject.com/en/dev/topics/cache/#template-fragment-caching
{% cache 500 sidebar request.user.username %}
{% if user.is_authenticated %}
{{ user.first_name}}
{% endif %}
{% endcache %}
The problem is my authenticated Name and picture is getting cached and seen by other users, and those of other users by some other user. Essentially anyone coming in hits the cache of previous chap visiting the web site.
Apart from this no user access or any other security issue is not there.
Can you advise why this is so and what is the solution to the problem.

Django: Online Users

I am following this solution to show whether a user is online or not.
But when I try to add:
'userprofile.middleware.ActiveUserMiddleware',
to MIDDLEWARE_CLASSES, I get a 502 error.
{{ profile.online }} returns false.
Thank you for any help.
UPDATE
It seems to work now without the middleware.
{% if object.profile.is_online %}
Online
{% else %}
Offline
{% endif %}
I have a list of users called "recommended".
{% recommended request user %}
Can I check within the template if these users are online?
{% recommended request user.is_online %}
does not work.
Thank you for any help / resource on this topic
I found a solution.
Django-online-users works perfectly fine.

How to check if user is in group with 'or something else' support in django template?

For now I used ifuseringroup tag but now I need to add exception for users with specific permission so I need something like this (pseudocode)
{% ifuseringroup 'masters' or perms.app_label.can_see_this %}
Anyone knows a group checking tag that will accept or and then standard django if tag expression?
Or can help me using other approach?
I'd go with this template filter:
{% if user|in_group:'masters' or perms.app_label.can_see_this %}
...
{% endif %}
If you are looking to check for permissions in templates, the following code would suffice:
{% if perms.app_label.can_do_something %}
<form here>
{% endif %}
Where model refers to the model that the user need permissions to see the form for.
Refer to https://docs.djangoproject.com/en/1.6/topics/auth/default/#permissions for more examples.
The currently logged-in user's permissions are stored in the template variable {{ perms }}

how to pass account information to django template in django-registration?

I want to pass the account information to the template so that when an user account is activated, there is a message saying "your account is activated; please log in now" with a link below. if the activation days have expired, it must say "activation days expired". I have url and template here, but I do not know how to pass the account information to the template.
url.py
urlpatterns = patterns('',
url(r'^activate/complete/$',
TemplateView.as_view(template_name='registration/activate.html'),
name='registration_activation_complete'),
......)
registration/activate.html
{% extends "registration/base.html" %}
{% block title %}Account activated{% endblock %}
{% block content %}
<h1>Account activated.</h1>
{% load humanize %}
{% if account %}
<p>Thanks for signing up! Now you can log in.</p>
{% else %}
<p>Sorry, it didn't work. Either your activation link was incorrect, or
the activation key for your account has expired; activation keys are
only valid for {{ expiration_days|apnumber }} days after
registration.</p>
{% endif %}
{% endblock %}
basically, I want to pass account and expiration_days to the above template. I just don't know how. help plz!
I'm afraid it won't be enough just to use TemplateView like you did; you'll have to write a custom view which will contain the logic for activation and pass the data to the template.

How to integrate a django-disqus app into a blog

Hi my client is desperate to integrate django disqus into the blog we have built for them. I stumbled upon https://github.com/arthurk/django-disqus django disqus app and couldnt believe my luck, i had this up and running in no time, everything appears to be working ok, im posting comments etc however it dosent seem to be identifying properly as a comment posted with object.id for one blog post appears for all posts through out the blog.
in the index template that lists all the blog posts out i have
{% for entry in entries %}
{% set_disqus_identifier entry.id %}
{% set_disqus_url entry.get_absolute_url %}
{% set_disqus_developer 1 %}
{% blog stuff goes here %}
{%endfor%}
in the article template i have
{% set_disqus_identifier entry.id %}
{% set_disqus_url entry.get_absolute_url %}
{% set_disqus_developer 1 %}
<section id="comments">
View Comments
<h1>{% disqus_num_replies %}</h1>
<article class="comment">
{% disqus_dev %}
{% disqus_show_comments entry.get_absolute_url %}
the problem as i mentioned before is that if i post one comment disqus is applying that to all the blog posts. I guess im doing something wrong with the identifiers, but when i view source the javascript is getting the right id for each blog post
I really need this to work so will be eternally grateful for any help or advice that has got this working
in your index template, you don't need to do all this set_* stuff. So just load the dev tag to enable local development:
{% disqus_dev %}
{% for entry in entries %}
{% blog stuff goes here %}
{% endfor %}
In your article template just do this to display the comments. The disqus javascript will use the current URL as the identifier, so there's no need to set it manually:
{% disqus_show_comments %}
Don't forget to set the settings to the correct values as described in the documentation: http://django-disqus.readthedocs.org/en/latest/installation.html#configuring-your-django-installation And also change the url of your Site object to your actual domain.
I think you should not set the identifier and other values in index template. Because of the for loop its overriding the previous values. Rather, you should set the values in template related to particular post. That way, you would be setting disqus parameters for that particular post.
Note: django-disqus has newer version now, with django 1.7 support.