Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User
- include DataMapper::Resource
- include DataMapper::Validate
- SchoolStatus = Enum[:prospective,:undergrad,:graduate,:faculty,:alumni,:none]
- property :id, Integer, :serial => true
- property :username, String, :nullable => false, :unique_index => true, :unique => true
- property :password, String, :nullable => false
- property :first_name, String, :nullable => false
- property :last_name, String, :nullable => false
- property :primary_email, String, :nullable => false, :unique => true, :unique_index => true
- property :class_year, String, :length => 4, :format => /^(\d{4})?$/
- property :school_status, SchoolStatus
- property :field_of_study, String
- property :residence, String
- has n, :email_accounts
- has n, :user_networks
- has n, :networks, :through => :user_networks, :class_name => 'Network'
- attr_accessor :email
- attr_accessor :network
- validates_present :email
- validates_present :network
- validates_length :password, :min => 6
- validates_length :username, :min => 1
- before :save, :transfer_properties
- def transfer_properties
- puts "in transfer properties"
- self.primary_email = self.email
- self.email_accounts << EmailAccount.new( :confirmed => false, :email => self.email )
- self.user_networks << UserNetwork.new( :network => Network.first( :network_type.eql => :site ) )
- self.user_networks << UserNetwork.new( :network => Network.get(self.network) )
- end
- end
Add Comment
Please, Sign In to add comment