Permalink
Browse files

added clans (Not tested yet)

  • Loading branch information...
1 parent 511f409 commit bd524d8f499f5af1ee34f4cffa8b8cc9fa554093 @junethack junethack committed Jun 9, 2011
Showing with 23 additions and 19 deletions.
  1. +4 −10 Rakefile.rb
  2. +1 −0 Readme.md
  3. +1 −0 database.rb
  4. +17 −2 models/account.rb
  5. +0 −7 server.rb
View
@@ -2,16 +2,7 @@
require 'database'
require 'fetch_games'
require 'date'
-task :testthis do
- bla = ["a","b","c","d"]
- for name in bla
- puts "executing task for #{name}"
- Rake::Task['testexec'].invoke name
- end
-end
-task :testexec do |t, args|
- puts "called with #{args.inspect}"
-end
+
namespace :bogus do
names = ["r4wrmage","ad3on","k3rio","bh44k","c4smith789", "st3nno"] #hi #junethack
@@ -24,6 +15,9 @@
end
Rake::Task['bogus:add_game'].invoke 20
end
+
+ task :add_server :name, :url, :xlogurl do |t, args|
+ Server.create(:name => args[:name], :url => args[:url], :xlogurl => args[:xlogurl]
task :add_servers do
Server.create(:name => "test server 1", :url => "localhost", :xlogurl => "file://test_xlog.txt", :xloglastmodified => "1.1.1970", :xlogcurrentoffset => 0)
View
@@ -15,6 +15,7 @@
- haml
- ruby-sqlite3
- datamapper
+ - dm-serializer
##Usage
Run the sinatra server with
View
@@ -9,6 +9,7 @@
require 'models/user'
require 'models/account'
require 'models/game'
+require 'models/clan'
DataMapper.finalize
DataMapper.auto_upgrade!
View
@@ -3,14 +3,29 @@ class Account #join model
include DataMapper::Resource
belongs_to :user, :key => true
- belongs_to :server, :key => true
-
+ belongs_to :server, :key => true, :lazy => false
+
+ belongs_to :clan, :required => false
property :name, String
property :verified, Boolean, :default => false
+ property :invitations, Json
+
def get_games
self.server.games.select{|game| game.name == self.name}
end
+
+ def invite invitation
+ self.invitations.push invitation
+ self.save
+ end
+
+ def respond_invite invitation, accept
+ if clan = Clan.get(invitation['clan_id'])
+ invitation['status'] = accept ? 'accept' : 'decline'
+ clan.get_invitation_response invitation
+ end
+ end
end
View
@@ -1,7 +0,0 @@
-require 'rubygems'
-require 'sinatra'
-require 'haml'
-
-get "/" do
- haml :index
-end

0 comments on commit bd524d8

Please sign in to comment.