added data columns to user for a unique access code that is theirs that they can give to others to invite them, and require people to give an access code to create an account.

This commit is contained in:
Connor Turland 2012-10-29 13:52:29 -04:00
parent f81ea7489f
commit f3fb5c5326
10 changed files with 56 additions and 13 deletions

View file

@ -30,7 +30,10 @@ h2 {display:block; text-align:center; font-family: "vinyl",sans-serif; backgroun
a {color:#2d6a5d; text-decoration:none;}
.clearfloat {clear:both;}
.new_session, .new_user, .new_item, .new_synapse, .new_map, .edit_user, .edit_item, .edit_synapse, .edit_map { display: block; width: 350px; position:absolute; left:50%; top:0; margin:200px 0 0 -195px; background: url('bg.png'); padding: 20px; border-radius: 15px; color: #000; border:2px solid #000; }
.new_session, .new_user, .new_item, .new_synapse, .new_map, .edit_user, .edit_item, .edit_synapse, .edit_map, .invite { display: block; width: 350px; position:absolute; left:50%; top:0; margin:200px 0 0 -195px; background: url('bg.png'); padding: 20px; border-radius: 15px; color: #000; border:2px solid #000; }
.invite p { margin:10px 0; }
.invite strong { text-align:center; display:block; color:#67AF9F; }
.anypage .new_item, .anypage .new_synapse { display: none; position:absolute; left:50%; top:0; margin:200px 0 0 -195px; border:2px solid #000; }
#closenewtopic, #closenewsynapse { position:absolute; top: 3px; right:3px; }

View file

@ -1,6 +1,8 @@
class MainController < ApplicationController
include ItemsHelper
before_filter :require_user, only: [:invite]
respond_to :html, :js, :json
#homepage pick a random map and show it
@ -38,5 +40,13 @@ class MainController < ApplicationController
end
end
def invite
@user = current_user
respond_to do |format|
format.html { respond_with(@user) }
end
end
end

View file

@ -34,9 +34,15 @@ class UsersController < ApplicationController
@user = User.create(params[:user])
#generate a random 8 letter/digit code that they can use to invite people
@user.code = rand(36**8).to_s(36)
@user.save
# direct them straight to the metamaps manual map.
@connor = User.find(555629996)
@map = Map.find(5)
respond_with(@user, location: root_url) do |format|
respond_with(@user, location: user_map_url(@connor,@map)) do |format|
end
end

View file

@ -16,10 +16,16 @@ has_many :mappings
end
validates :password, :presence => true,
:length => {:within => 6..20},
:length => {
:maximum => 20,
:too_long => "is too long (maximum is %{count} characters)" },
:on => :create
validates :password, :length => {:within => 6..20},
:allow_blank => true,
validates :password, :allow_blank => true,
:length => {
:maximum => 20,
:too_long => "is too long (maximum is %{count} characters)"},
:on => :update
validates :joinedwithcode, :presence => true, :inclusion => { :in => User.all.map(&:code), :message => "%{value} is not a valid code" }, :on => :create
end

View file

@ -51,12 +51,16 @@
<div class="headertop">
<h1 id="mainTitle"><%= link_to "metamaps", root_url %></h1>&nbsp;beta
<% unless authenticated? %>
<ul>
<ul id="menus">
<li><%= link_to "Login", new_session_path, id: "Login" %></li>
<li>|</li>
<li><%= link_to "Maps", allmaps_path %></li>
<li>|</li>
<li><%= link_to "All", metamap_path %></li>
<li class="exploreWrap">
<p id="explore">Explore</p>
<ul class="explore">
<li class="first"><%= link_to "Maps", allmaps_path %></li>
<li class="last"><%= link_to "Metamap", metamap_path %></li>
</ul>
</li>
</ul>
<% end %>
<% if authenticated? %>
@ -67,6 +71,7 @@
<li class="first"><%= link_to "My Topics", user_items_url(user) %></li>
<li><%= link_to "My Synapses", user_synapses_url(user) %></li>
<li><%= link_to "My Maps", user_maps_url(user) %></li>
<li><%= link_to "Invite", invite_path %></li>
<li><%= link_to "Settings", edit_user_url(user) %></li>
<li class="last"><%= link_to "Logout", session_path, method: 'delete', id: "Login" %></li>
</ul>

View file

@ -0,0 +1,6 @@
<div class="invite">
<h3>Invite Others</h3>
<p>You can invite others to the Metamaps platform. Just send them the link to</p><p><strong>http://metamaps.cc/users/new</strong></p><p>and give them the access code shown below.</p>
<div class="code"><strong><%= @user.code %></strong></div>
<p>We invite you to be conscious as to who you invite to this platform, because much of the collaborative editing is based on trust. We want to cultivate a community here that is fun, wise, creative, and flourishing. Can you help us build a community like that?</p>
</div>

View file

@ -3,7 +3,8 @@
<%= form.input :name, label: "Name", class: "name" %>
<%= form.input :email, label: "Email", class: "email" %>
<%= form.input :password, label: "Password", class: "password" %>
<%= form.submit "Login", class: "add" %>
<%= form.input :joinedwithcode, label: "Access Code", class: "joinedwithcode" %>
<%= form.submit "Create Account", class: "add" %>
<% end %>

View file

@ -5,6 +5,8 @@ ISSAD::Application.routes.draw do
match 'metamap', to: 'main#metamap', via: :get, as: :metamap
match 'maps', to: 'main#allmaps', via: :get, as: :allmaps
match 'invite', to: 'main#invite', via: :get, as: :invite
resource :session
resources :users do

View file

@ -3,6 +3,8 @@ class CreateUsers < ActiveRecord::Migration
create_table :users do |t|
t.string :name
t.string :email
t.string :code, :limit => 8
t.string :joinedwithcode, :limit => 8
t.string :crypted_password
t.string :password_salt
t.string :persistence_token

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20121026103129) do
ActiveRecord::Schema.define(:version => 20121029164735) do
create_table "item_categories", :force => true do |t|
t.text "name"
@ -71,8 +71,10 @@ ActiveRecord::Schema.define(:version => 20121026103129) do
t.string "password_salt"
t.string "persistence_token"
t.string "perishable_token"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "code", :limit => 8
t.string "joinedwithcode", :limit => 8
end
end