File: auth-models.cpp

package info (click to toggle)
qdjango 0.6.2-3.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 908 kB
  • sloc: cpp: 7,818; sh: 32; makefile: 12; javascript: 1
file content (204 lines) | stat: -rw-r--r-- 3,534 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/*
 * Copyright (C) 2010-2015 Jeremy Lainé
 * Contact: https://github.com/jlaine/qdjango
 *
 * This file is part of the QDjango Library.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 */

#include "QDjangoQuerySet.h"

#include "auth-models.h"

User::User(QObject *parent)
    : QDjangoModel(parent),
    m_isActive(true),
    m_isStaff(false),
    m_isSuperUser(false)
{
    // initialise dates
    m_dateJoined = QDateTime::currentDateTime();
    m_lastLogin = QDateTime::currentDateTime();
}

QString User::username() const
{
    return m_username;
}

void User::setUsername(const QString &username)
{
    m_username = username;
}

QString User::firstName() const
{
    return m_firstName;
}

void User::setFirstName(const QString &firstName)
{
    m_firstName = firstName;
}

QString User::lastName() const
{
    return m_lastName;
}

void User::setLastName(const QString &lastName)
{
    m_lastName = lastName;
}

QString User::email() const
{
    return m_email;
}

void User::setEmail(const QString &email)
{
    m_email = email;
}

QString User::password() const
{
    return m_password;
}

void User::setPassword(const QString &password)
{
    m_password = password;
}

bool User::isActive() const
{
    return m_isActive;
}

void User::setIsActive(bool isActive)
{
    m_isActive = isActive;
}

bool User::isStaff() const
{
    return m_isStaff;
}

void User::setIsStaff(bool isStaff)
{
    m_isStaff = isStaff;
}

bool User::isSuperUser() const
{
    return m_isSuperUser;
}

void User::setIsSuperUser(bool isSuperUser)
{
    m_isSuperUser = isSuperUser;
}

QDateTime User::dateJoined() const
{
    return m_dateJoined;
}

void User::setDateJoined(const QDateTime &dateJoined)
{
    m_dateJoined = dateJoined;
}

QDateTime User::lastLogin() const
{
    return m_lastLogin;
}

void User::setLastLogin(const QDateTime &lastLogin)
{
    m_lastLogin = lastLogin;
}

Group::Group(QObject *parent)
    : QDjangoModel(parent)
{
}

QString Group::name() const
{
    return m_name;
}

void Group::setName(const QString &name)
{
    m_name = name;
}

UserGroups::UserGroups(QObject *parent)
    : QDjangoModel(parent)
{
    setForeignKey("user", new User(this));
    setForeignKey("group", new Group(this));
}

User *UserGroups::user() const
{
    return qobject_cast<User*>(foreignKey("user"));
}

void UserGroups::setUser(User *user)
{
    setForeignKey("user", user);
}

Group *UserGroups::group() const
{
    return qobject_cast<Group*>(foreignKey("group"));
}

void UserGroups::setGroup(Group *group)
{
    setForeignKey("group", group);
}

Message::Message(QObject *parent)
    : QDjangoModel(parent)
{
    setForeignKey("user", new User(this));
}

/** Returns the User associated with this Message.
 */
User *Message::user() const
{
    return qobject_cast<User*>(foreignKey("user"));
}

void Message::setUser(User *user)
{
    setForeignKey("user", user);
}

QString Message::message() const
{
    return m_message;
}

void Message::setMessage(const QString &message)
{
    m_message = message;
}

Q_DECLARE_METATYPE(Group*)
Q_DECLARE_METATYPE(User*)