      1 // The Antville Project
      2 // http://code.google.com/p/antville
      3 //
      4 // Copyright 2007-2011 by Tobi Schäfer.
      5 //
      6 // Copyright 2001–2007 Robert Gaggl, Hannes Wallnöfer, Tobi Schäfer,
      7 // Matthias & Michael Platzer, Christoph Lincke.
      8 //
      9 // Licensed under the Apache License, Version 2.0 (the ``License'');
     10 // you may not use this file except in compliance with the License.
     11 // You may obtain a copy of the License at
     12 //
     13 //    http://www.apache.org/licenses/LICENSE-2.0
     14 //
     15 // Unless required by applicable law or agreed to in writing, software
     16 // distributed under the License is distributed on an ``AS IS'' BASIS,
     17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     18 // See the License for the specific language governing permissions and
     19 // limitations under the License.
     20 //
     21 // $Revision$
     22 // $LastChangedBy$
     23 // $LastChangedDate$
     24 // $URL$
     25
     26 /**
     27  * @fileOverview Defines the Vote prototype.
     28  */
     29
     30 markgettext("Vote");
     31 markgettext("vote");
     32
     33 /**
     34  * @param {Choice} choice
     35  * @returns {Vote}
     36  */
     37 Vote.add = function(choice, poll) {
     38    HopObject.confirmConstructor(Vote);
     39    var vote = new Vote;
     40    vote.choice = choice;
     41    vote.creator = session.user;
     42    vote.creator_name = session.user.name;
     43    vote.created = vote.modified = new Date;
     44    poll.votes.add(vote);
     45 	return vote;
     46 }
     47
     48 /**
     49  * @name Vote
     50  * @constructor
     51  * @property {Choice} choice
     52  * @property {Date} created
     53  * @property {User} creator
     54  * @property {String} creator_name
     55  * @property {Date} modified
     56  * @property {Poll} poll
     57  * @extends HopObject
     58  */
     59 Vote.prototype.constructor = function(choice) {
     60    HopObject.confirmConstructor(this);
     61    return this;
     62 }
     63