2 # This file is part of my.gpodder.org.
4 # my.gpodder.org is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or (at your
7 # option) any later version.
9 # my.gpodder.org is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
12 # License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with my.gpodder.org. If not, see <http://www.gnu.org/licenses/>.
20 from mygpo
.users
.settings
import STORE_UA
21 from mygpo
.users
.models
import Client
24 def get_device(user
, uid
, user_agent
, undelete
=True):
26 Loads or creates the device indicated by user, uid.
28 If the device has been deleted and undelete=True, it is undeleted.
31 store_ua
= user
.profile
.get_wksetting(STORE_UA
)
35 client
, created
= Client
.objects
.get_or_create(user
=user
, uid
=uid
,
40 if client
.deleted
and undelete
:
41 client
.deleted
= False
44 if store_ua
and user_agent
and client
.user_agent
!= user_agent
:
45 client
.user_agent
= user_agent