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
367a6f06
Commit
367a6f06
authored
Oct 08, 2013
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create anonymous user for anonymous user privileges
parent
2206df51
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
4 deletions
+42
-4
accounts/models.py
accounts/models.py
+26
-4
docs/config.rst
docs/config.rst
+10
-0
weblate/appsettings.py
weblate/appsettings.py
+3
-0
weblate/settings_example.py
weblate/settings_example.py
+3
-0
No files found.
accounts/models.py
View file @
367a6f06
...
@@ -18,14 +18,16 @@
...
@@ -18,14 +18,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
from
django.db
import
models
from
django.db
import
models
,
IntegrityError
from
django.dispatch
import
receiver
from
django.dispatch
import
receiver
from
django.conf
import
settings
from
django.conf
import
settings
from
django.contrib.auth.signals
import
user_logged_in
from
django.contrib.auth.signals
import
user_logged_in
from
django.db.models.signals
import
post_save
from
django.db.models.signals
import
post_save
from
django.utils.translation
import
ugettext_lazy
as
_
,
gettext
from
django.utils.translation
import
ugettext_lazy
as
_
,
gettext
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.contrib.auth.models
import
Group
,
Permission
,
User
from
django.contrib.auth.models
import
(
Group
,
User
,
UNUSABLE_PASSWORD
,
Permission
)
from
django.db.models.signals
import
post_syncdb
from
django.db.models.signals
import
post_syncdb
from
registration.signals
import
user_registered
from
registration.signals
import
user_registered
from
django.contrib.sites.models
import
Site
from
django.contrib.sites.models
import
Site
...
@@ -41,6 +43,7 @@ from trans.util import (
...
@@ -41,6 +43,7 @@ from trans.util import (
get_user_display
,
get_site_url
,
get_distinct_translations
get_user_display
,
get_site_url
,
get_distinct_translations
)
)
import
weblate
import
weblate
from
weblate.appsettings
import
ANONYMOUS_USER_NAME
def
notify_merge_failure
(
subproject
,
error
,
status
):
def
notify_merge_failure
(
subproject
,
error
,
status
):
...
@@ -564,9 +567,9 @@ def create_groups(update):
...
@@ -564,9 +567,9 @@ def create_groups(update):
'''
'''
Creates standard groups and gives them permissions.
Creates standard groups and gives them permissions.
'''
'''
group
,
created
=
Group
.
objects
.
get_or_create
(
name
=
'Guests'
)
g
uest_g
roup
,
created
=
Group
.
objects
.
get_or_create
(
name
=
'Guests'
)
if
created
or
update
:
if
created
or
update
:
group
.
permissions
.
add
(
g
uest_g
roup
.
permissions
.
add
(
Permission
.
objects
.
get
(
codename
=
'can_see_git_repository'
),
Permission
.
objects
.
get
(
codename
=
'can_see_git_repository'
),
)
)
...
@@ -617,6 +620,25 @@ def create_groups(update):
...
@@ -617,6 +620,25 @@ def create_groups(update):
Permission
.
objects
.
get
(
codename
=
'delete_comment'
),
Permission
.
objects
.
get
(
codename
=
'delete_comment'
),
)
)
try
:
anon_user
,
created
=
User
.
objects
.
get_or_create
(
username
=
ANONYMOUS_USER_NAME
,
password
=
UNUSABLE_PASSWORD
,
is_active
=
False
,
)
if
created
or
update
:
anon_user
.
groups
.
clear
()
anon_user
.
groups
.
add
(
guest_group
)
except
IntegrityError
as
error
:
raise
ValueError
(
'Anonymous user (%s) already exists and enabled, '
'please change ANONYMOUS_USER_NAME setting.
\
n
'
'Raised error was: %s'
%
(
ANONYMOUS_USER_NAME
,
repr
(
error
)
)
)
def
move_users
():
def
move_users
():
'''
'''
...
...
docs/config.rst
View file @
367a6f06
...
@@ -32,6 +32,16 @@ be an integer.
...
@@ -32,6 +32,16 @@ be an integer.
This is actually django-registration settings.
This is actually django-registration settings.
.. setting:: ANONYMOUS_USER_NAME
ANONYMOUS_USER_NAME
-------------------
User name of user for definining privileges of not logged in user.
.. seealso:: :ref:`privileges`
.. setting:: AUTO_LOCK
.. setting:: AUTO_LOCK
AUTO_LOCK
AUTO_LOCK
...
...
weblate/appsettings.py
View file @
367a6f06
...
@@ -142,3 +142,6 @@ SCRIPT_CHOICES = [
...
@@ -142,3 +142,6 @@ SCRIPT_CHOICES = [
# Font for charts and widgets
# Font for charts and widgets
TTF_PATH
=
get
(
'TTF_PATH'
,
os
.
path
.
join
(
WEB_ROOT
,
'ttf'
))
TTF_PATH
=
get
(
'TTF_PATH'
,
os
.
path
.
join
(
WEB_ROOT
,
'ttf'
))
# Anonymous user name
ANONYMOUS_USER_NAME
=
get
(
'ANONYMOUS_USER_NAME'
,
'anonymous'
)
weblate/settings_example.py
View file @
367a6f06
...
@@ -349,6 +349,9 @@ ACCOUNT_ACTIVATION_DAYS = 7
...
@@ -349,6 +349,9 @@ ACCOUNT_ACTIVATION_DAYS = 7
# Profile module
# Profile module
AUTH_PROFILE_MODULE
=
'accounts.Profile'
AUTH_PROFILE_MODULE
=
'accounts.Profile'
# Anonymous user name
ANONYMOUS_USER_NAME
=
'anonymous'
# Sending HTML in mails
# Sending HTML in mails
EMAIL_SEND_HTML
=
False
EMAIL_SEND_HTML
=
False
...
...
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