Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
cb7a23a7
Commit
cb7a23a7
authored
Sep 07, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add management command to change site name.
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
8a040682
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
115 additions
and
23 deletions
+115
-23
docs/admin/install.rst
docs/admin/install.rst
+10
-5
docs/admin/management.rst
docs/admin/management.rst
+12
-0
docs/changes.rst
docs/changes.rst
+1
-0
docs/faq.rst
docs/faq.rst
+2
-4
openshift/install.sh
openshift/install.sh
+5
-14
weblate/accounts/management/commands/changesite.py
weblate/accounts/management/commands/changesite.py
+68
-0
weblate/accounts/tests.py
weblate/accounts/tests.py
+17
-0
No files found.
docs/admin/install.rst
View file @
cb7a23a7
...
...
@@ -443,12 +443,17 @@ Set correct site name
Adjust site name in admin interface, otherwise links in RSS or registration
emails will not work.
You can do this under the :guilabel:`Sites › Sites` (or directly open URL
``/admin/sites/site/1/``), change the :guilabel:`Domain name` to match your
setup. You might want to set :setting:`ENABLE_HTTPS` as well if you serve site
over https
.
Please open admin interface and edit default site name and domain under the
:guilabel:`Sites › Sites` (or you can do that directly at
``/admin/sites/site/1/`` URL under your Weblate installation). You have to change
the :guilabel:`Domain name` to match your setup
.
.. seealso:: :ref:`faq-site`
You might want to set :setting:`ENABLE_HTTPS` as well if you serve site over
https.
Alternatively you can set the site name from command line using :djadmin:`changesite`.
.. seealso:: :ref:`faq-site`, :djadmin:`changesite`, https://docs.djangoproject.com/en/stable/ref/contrib/sites/
.. _production-indexing:
...
...
docs/admin/management.rst
View file @
cb7a23a7
...
...
@@ -11,6 +11,18 @@ Management commands
The ./manage.py is extended with following commands:
changesite
----------
.. django-admin:: changesite
.. versionadded:: 2.4
You can use this to changes site name from command line with ``--set-name``
parameter. The ``--get-name`` prints currently configured site name.
.. seealso:: :ref:`production-site`
checkgit <project|project/component>
------------------------------------
...
...
docs/changes.rst
View file @
cb7a23a7
...
...
@@ -32,6 +32,7 @@ Released on ? 2015.
* Rewritten handling of static files.
* Direct login/registration links to third party service if that's the only one.
* Commit pending changes on account removal.
* Add management command to change site name.
weblate 2.3
-----------
...
...
docs/faq.rst
View file @
cb7a23a7
...
...
@@ -117,11 +117,9 @@ Why does registration contain example.com as domain?
----------------------------------------------------
Weblate uses Django sites framework and it defines site name inside the
database. Please open admin interface and edit default site name and domain
(you can do that directly at ``/admin/sites/site/1/`` URL under your Weblate
installation).
database.
.. seealso::
https://docs.djangoproject.com/en/stable/ref/contrib/sites/
.. seealso::
:ref:`production-site`
Why are all commits committed by Weblate <noreply@weblate.org>?
---------------------------------------------------------------
...
...
openshift/install.sh
View file @
cb7a23a7
...
...
@@ -65,29 +65,20 @@ done < $OPENSHIFT_REPO_DIR/requirements-optional.txt
sh
"python
${
OPENSHIFT_REPO_DIR
}
/setup_weblate.py develop"
if
[
!
-s
$OPENSHIFT_REPO_DIR
/weblate/fixtures/site_data.json
]
;
then
mkdir
-p
$OPENSHIFT_REPO_DIR
/weblate/fixtures
cat
<<-
EOF
>
$OPENSHIFT_REPO_DIR
/weblate/fixtures/site_data.json
[{
"pk": 1,
"model": "sites.site",
"fields": {
"name": "
${
OPENSHIFT_APP_DNS
}
",
"domain":"
${
OPENSHIFT_APP_DNS
}
"
}
}]
EOF
fi
sh
"python
${
OPENSHIFT_REPO_DIR
}
/openshift/manage.py migrate --noinput"
sh
"python
${
OPENSHIFT_REPO_DIR
}
/openshift/manage.py collectstatic --noinput"
if
[
!
-s
$OPENSHIFT_DATA_DIR
/.credentials
]
;
then
sh
"python
${
OPENSHIFT_REPO_DIR
}
/openshift/manage.py changesite
${
OPENSHIFT_APP_DNS
}
"
fi
if
[
!
-s
$OPENSHIFT_DATA_DIR
/.credentials
]
;
then
sh
"python
${
OPENSHIFT_REPO_DIR
}
/openshift/manage.py setupgroups --move"
else
sh
"python
${
OPENSHIFT_REPO_DIR
}
/openshift/manage.py setupgroups --no-privs-update"
fi
sh
"python
${
OPENSHIFT_REPO_DIR
}
/openshift/manage.py setuplang"
sh
"python
${
OPENSHIFT_REPO_DIR
}
/openshift/manage.py compilemessages"
...
...
weblate/accounts/management/commands/changesite.py
0 → 100644
View file @
cb7a23a7
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2015 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <http://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.contrib.sites.models
import
Site
from
optparse
import
make_option
class
Command
(
BaseCommand
):
help
=
'changes default site name'
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'--set-name'
,
type
=
'str'
,
dest
=
'set_name'
,
default
=
None
,
help
=
'site name to set'
),
make_option
(
'--site-id'
,
type
=
'int'
,
dest
=
'site_id'
,
default
=
1
,
help
=
'site ID to manipulate (1 by default)'
),
make_option
(
'--get-name'
,
action
=
'store_true'
,
dest
=
'get_name'
,
default
=
False
,
help
=
'just display the site name'
),
)
def
handle
(
self
,
*
args
,
**
options
):
if
options
[
'set_name'
]:
site
,
created
=
Site
.
objects
.
get_or_create
(
pk
=
options
[
'site_id'
],
defaults
=
{
'domain'
:
options
[
'set_name'
],
'name'
:
options
[
'set_name'
]}
)
if
not
created
:
site
.
domain
=
options
[
'set_name'
]
site
.
name
=
options
[
'set_name'
]
site
.
save
()
elif
options
[
'get_name'
]:
try
:
self
.
stdout
.
write
(
Site
.
objects
.
get
(
pk
=
options
[
'site_id'
]).
domain
)
except
Site
.
DoesNotExist
:
raise
CommandError
(
'Site does not exist!'
)
else
:
raise
CommandError
(
'Please specify desired action!'
)
weblate/accounts/tests.py
View file @
cb7a23a7
...
...
@@ -28,9 +28,11 @@ from django.test import TestCase
from
unittest
import
SkipTest
from
django.core.urlresolvers
import
reverse
from
django.contrib.auth.models
import
AnonymousUser
,
User
,
Group
from
django.contrib.sites.models
import
Site
from
django.core
import
mail
from
django.test.utils
import
override_settings
from
django.core.management
import
call_command
from
django.core.management.base
import
CommandError
from
django.http
import
HttpRequest
,
HttpResponseRedirect
from
weblate.accounts.models
import
(
...
...
@@ -316,6 +318,21 @@ class CommandTest(TestCase):
profile
=
Profile
.
objects
.
get
(
user__username
=
'testuser'
)
self
.
assertEqual
(
profile
.
translated
,
2000
)
def
test_changesite
(
self
):
call_command
(
'changesite'
,
get_name
=
True
)
self
.
assertNotEqual
(
Site
.
objects
.
get
(
pk
=
1
).
domain
,
'test.weblate.org'
)
call_command
(
'changesite'
,
set_name
=
'test.weblate.org'
)
self
.
assertEqual
(
Site
.
objects
.
get
(
pk
=
1
).
domain
,
'test.weblate.org'
)
def
test_changesite_new
(
self
):
self
.
assertRaises
(
CommandError
,
call_command
,
'changesite'
,
get_name
=
True
,
site_id
=
2
)
call_command
(
'changesite'
,
set_name
=
'test.weblate.org'
,
site_id
=
2
)
self
.
assertEqual
(
Site
.
objects
.
get
(
pk
=
2
).
domain
,
'test.weblate.org'
)
class
ViewTest
(
TestCase
):
'''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment