Merge remote-tracking branch 'openslides/stable/1.4.x'
Conflicts: openslides/core/templatetags/tags.py
This commit is contained in:
commit
20cf960c82
@ -520,6 +520,9 @@ class MainWindow(wx.Frame):
|
|||||||
if not last_backup is None:
|
if not last_backup is None:
|
||||||
self.last_backup = datetime.datetime.strptime(
|
self.last_backup = datetime.datetime.strptime(
|
||||||
last_backup, "%Y-%m-%d %H:%M:%S")
|
last_backup, "%Y-%m-%d %H:%M:%S")
|
||||||
|
server_settings = settings.get("server_settings", {})
|
||||||
|
setattr_unless_none("host", server_settings.get("host"))
|
||||||
|
setattr_unless_none("port", server_settings.get("port"))
|
||||||
|
|
||||||
def save_gui_settings(self):
|
def save_gui_settings(self):
|
||||||
if self.last_backup is None:
|
if self.last_backup is None:
|
||||||
@ -534,6 +537,9 @@ class MainWindow(wx.Frame):
|
|||||||
"interval_unit": self.backupdb_interval_unit,
|
"interval_unit": self.backupdb_interval_unit,
|
||||||
"last_backup": last_backup
|
"last_backup": last_backup
|
||||||
},
|
},
|
||||||
|
"server_settings": {
|
||||||
|
"host": self.host,
|
||||||
|
"port": self.port,
|
||||||
}
|
}
|
||||||
|
|
||||||
dp = os.path.dirname(self.gui_settings_path)
|
dp = os.path.dirname(self.gui_settings_path)
|
||||||
@ -613,7 +619,10 @@ class MainWindow(wx.Frame):
|
|||||||
self.cmd_run_ctrl.cancel_command()
|
self.cmd_run_ctrl.cancel_command()
|
||||||
return
|
return
|
||||||
|
|
||||||
args = ["--address", self._host, "--port", self._port]
|
if self._host == "0.0.0.0":
|
||||||
|
args = ["--port", self._port]
|
||||||
|
else:
|
||||||
|
args = ["--address", self._host, "--port", self._port]
|
||||||
if not self.cb_start_browser.GetValue():
|
if not self.cb_start_browser.GetValue():
|
||||||
args.append("--no-browser")
|
args.append("--no-browser")
|
||||||
|
|
||||||
|
@ -39,7 +39,10 @@ def trans(value):
|
|||||||
def model_url(object, link='view'):
|
def model_url(object, link='view'):
|
||||||
warnings.warn("model_url is deprecated; use absolute_url instead",
|
warnings.warn("model_url is deprecated; use absolute_url instead",
|
||||||
DeprecationWarning)
|
DeprecationWarning)
|
||||||
return object.get_absolute_url(link)
|
try:
|
||||||
|
return object.get_absolute_url(link)
|
||||||
|
except ValueError:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
|
@ -51,6 +51,20 @@ class Person(object):
|
|||||||
"""
|
"""
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
def get_absolute_url(self, link='detail'):
|
||||||
|
"""
|
||||||
|
Return an absolute url for the person.
|
||||||
|
|
||||||
|
The argument 'link' affects which url it is. Typically it is one of:
|
||||||
|
* detail
|
||||||
|
* edit
|
||||||
|
* delete
|
||||||
|
|
||||||
|
You should raise an 'ValueError', if your person does not have
|
||||||
|
one of this links.
|
||||||
|
"""
|
||||||
|
raise ValueError('This person object has no url.')
|
||||||
|
|
||||||
|
|
||||||
class Persons(object):
|
class Persons(object):
|
||||||
"""
|
"""
|
||||||
|
@ -81,7 +81,7 @@ class PersonMixin(object):
|
|||||||
% self)
|
% self)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return 'MyPerson: %s' % self.person_id
|
return self.person_id
|
||||||
|
|
||||||
def prepare_database_save(self, field):
|
def prepare_database_save(self, field):
|
||||||
if type(field) is PersonField:
|
if type(field) is PersonField:
|
||||||
|
@ -13,6 +13,9 @@ class TestPerson(PersonMixin, models.Model):
|
|||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def get_absolute_url(self, link='detail'):
|
||||||
|
return 'absolute_url_of_test_person'
|
||||||
|
|
||||||
|
|
||||||
class TestPersonToPerson(object):
|
class TestPersonToPerson(object):
|
||||||
def __init__(self, person_prefix_filter=None, id_filter=None):
|
def __init__(self, person_prefix_filter=None, id_filter=None):
|
||||||
|
@ -15,11 +15,12 @@ from django.db.models.query import EmptyQuerySet
|
|||||||
from django.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
|
|
||||||
from openslides.utils.test import TestCase
|
from openslides.utils.test import TestCase
|
||||||
|
from openslides.utils.person.api import get_person
|
||||||
|
|
||||||
from .models import TestPerson, TestModel
|
from .models import TestPerson, TestModel
|
||||||
|
|
||||||
|
|
||||||
class ItemTest(TestCase):
|
class PersonTest(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.person1 = TestPerson.objects.create(name='test1')
|
self.person1 = TestPerson.objects.create(name='test1')
|
||||||
|
|
||||||
@ -45,3 +46,12 @@ class ItemTest(TestCase):
|
|||||||
AttributeError,
|
AttributeError,
|
||||||
'You can not save \'<type \'int\'>\' into a person field.'):
|
'You can not save \'<type \'int\'>\' into a person field.'):
|
||||||
TestModel.objects.create(person=5)
|
TestModel.objects.create(person=5)
|
||||||
|
|
||||||
|
def test_get_absolute_url_with_deleted_person(self):
|
||||||
|
person2 = TestPerson.objects.create(name='test2')
|
||||||
|
self.assertEqual(person2.get_absolute_url(), 'absolute_url_of_test_person')
|
||||||
|
person_id = person2.person_id
|
||||||
|
self.assertEqual(get_person(person_id).get_absolute_url(), 'absolute_url_of_test_person')
|
||||||
|
person2.delete()
|
||||||
|
with self.assertRaisesRegexp(ValueError, 'This person object has no url.'):
|
||||||
|
get_person(person_id).get_absolute_url()
|
||||||
|
Loading…
Reference in New Issue
Block a user