Fixed saving anonymous user in a PersonField
This commit is contained in:
parent
e755712403
commit
f581169e1e
@ -11,6 +11,7 @@
|
||||
"""
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
|
||||
from openslides.config.api import config
|
||||
from openslides.projector.projector import Widget
|
||||
@ -20,7 +21,10 @@ def get_widgets(request):
|
||||
"""
|
||||
Returns the widgets of the account app. It is only a personal_info_widget.
|
||||
"""
|
||||
return [get_personal_info_widget(request)]
|
||||
if not isinstance(request.user, AnonymousUser):
|
||||
return [get_personal_info_widget(request)]
|
||||
else:
|
||||
return []
|
||||
|
||||
|
||||
def get_personal_info_widget(request):
|
||||
|
@ -151,11 +151,11 @@
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
{% if is_speaker %}
|
||||
<a href="{% url 'agenda_speaker_delete' object.id %}" class="btn">{% trans "Remove me from the list" %}</a>
|
||||
{% elif not object.speaker_list_closed %}
|
||||
<a href="{% url 'agenda_speaker_append' object.id %}" class="btn">{% trans "Put me on the list" %}</a>
|
||||
{% endif %}
|
||||
{% if is_speaker %}
|
||||
<a href="{% url 'agenda_speaker_delete' object.id %}" class="btn">{% trans "Remove me from the list" %}</a>
|
||||
{% elif not object.speaker_list_closed and perms.can_be_speaker %}
|
||||
<a href="{% url 'agenda_speaker_append' object.id %}" class="btn">{% trans "Put me on the list" %}</a>
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% if perms.can_manage_agenda %}
|
||||
|
@ -11,6 +11,8 @@
|
||||
"""
|
||||
from django.db import models
|
||||
|
||||
from openslides.utils.exceptions import OpenSlidesError
|
||||
|
||||
from .forms import PersonFormField
|
||||
from .api import get_person, generate_person_id
|
||||
|
||||
@ -41,11 +43,16 @@ class PersonField(models.fields.Field):
|
||||
Convert a person object to a string, to store it in the database.
|
||||
"""
|
||||
if value is None:
|
||||
# For Fields with null=True
|
||||
return None
|
||||
elif isinstance(value, basestring):
|
||||
# The object is already a a person_id
|
||||
return value
|
||||
else:
|
||||
elif hasattr(value, 'person_id'):
|
||||
# The object is a person
|
||||
return value.person_id
|
||||
else:
|
||||
OpenSlidesError('%s (%s) is no person' % (value, type(value)))
|
||||
|
||||
def formfield(self, **kwargs):
|
||||
defaults = {'form_class': PersonFormField}
|
||||
|
Loading…
Reference in New Issue
Block a user