Add Groups
This commit is contained in:
43
js/models.js
43
js/models.js
@ -10,6 +10,8 @@ function getJSONObj(json_input) {
|
||||
|
||||
function User() {
|
||||
this.UserId = -1;
|
||||
this.GroupId = -1;
|
||||
this.GroupPassword = "";
|
||||
this.Name = "";
|
||||
this.Username = "";
|
||||
this.Password = "";
|
||||
@ -19,6 +21,8 @@ function User() {
|
||||
User.prototype.toJSON = function() {
|
||||
var json_obj = {};
|
||||
json_obj.UserId = this.UserId;
|
||||
json_obj.GroupId = this.GroupId;
|
||||
json_obj.GroupPassword = this.GroupPassword;
|
||||
json_obj.Name = this.Name;
|
||||
json_obj.Username = this.Username;
|
||||
json_obj.Password = this.Password;
|
||||
@ -31,6 +35,10 @@ User.prototype.fromJSON = function(json_input) {
|
||||
|
||||
if (json_obj.hasOwnProperty("UserId"))
|
||||
this.UserId = json_obj.UserId;
|
||||
if (json_obj.hasOwnProperty("GroupId"))
|
||||
this.GroupId = json_obj.GroupId;
|
||||
if (json_obj.hasOwnProperty("GroupPassword"))
|
||||
this.GroupPassword = json_obj.GroupPassword;
|
||||
if (json_obj.hasOwnProperty("Name"))
|
||||
this.Name = json_obj.Name;
|
||||
if (json_obj.hasOwnProperty("Username"))
|
||||
@ -43,10 +51,42 @@ User.prototype.fromJSON = function(json_input) {
|
||||
|
||||
User.prototype.isUser = function() {
|
||||
var empty_user = new User();
|
||||
return this.UserId != empty_user.UserId ||
|
||||
return this.UserId != empty_user.UserId &&
|
||||
this.GroupId != empty_user.GroupId &&
|
||||
this.Username != empty_user.Username;
|
||||
}
|
||||
|
||||
function Group() {
|
||||
this.GroupId = -1;
|
||||
this.Name = "";
|
||||
this.Password = "";
|
||||
}
|
||||
|
||||
Group.prototype.toJSON = function() {
|
||||
var json_obj = {};
|
||||
json_obj.GroupId = this.GroupId;
|
||||
json_obj.Name = this.Name;
|
||||
json_obj.Password = this.Password;
|
||||
return JSON.stringify(json_obj);
|
||||
}
|
||||
|
||||
Group.prototype.fromJSON = function(json_input) {
|
||||
var json_obj = getJSONObj(json_input);
|
||||
|
||||
if (json_obj.hasOwnProperty("GroupId"))
|
||||
this.GroupId = json_obj.GroupId;
|
||||
if (json_obj.hasOwnProperty("Name"))
|
||||
this.Name = json_obj.Name;
|
||||
if (json_obj.hasOwnProperty("Password"))
|
||||
this.Password = json_obj.Password;
|
||||
}
|
||||
|
||||
Group.prototype.isGroup = function() {
|
||||
var empty_group = new Group();
|
||||
return this.GroupId != empty_group.GroupId &&
|
||||
this.Name != empty_group.Name;
|
||||
}
|
||||
|
||||
function Session() {
|
||||
this.SessionId = -1;
|
||||
this.UserId = -1;
|
||||
@ -253,6 +293,7 @@ module.exports = models = {
|
||||
|
||||
// Classes
|
||||
User: User,
|
||||
Group: Group,
|
||||
Session: Session,
|
||||
Error: Error,
|
||||
Attendee: Attendee,
|
||||
|
Reference in New Issue
Block a user