Need for some signed emails to test Gentoo recruiters application

2010/10/05 at 10:27 pm (2010, GSoC 2010, Hobo, Planet Gentoo, Ruby on Rails, WebApplication)

I did some work on web application for Gentoo Recruiters after end of Google Summer. One thing I (hopefully) finished is signatures validation. To make sure the application works properly I need sample singed emails from various email clients.

To help me testing please create a signed email using your email client and send it to jbartosik[at]gmail[dot]com (or save it and pastebin it if you prefer).  Please use detached/ mime signature. Also feel free to use outdated/fake keys.

Permalink 2 Comments

Released hobo-openid gem

2010/08/04 at 6:47 pm (2010, Hobo, Programming, Ruby on Rails, WebApplication)

I released hobo_openid to RubyGems ( here :) ).  It still needs work but is usable. To add OpenID support to your Hobo application install hobo_openid gem and change your application a bit.

Modify user model

First you need to add field storing OpenID to your User model. Open app/models/user.rb and add

openid        :string

field.

Modify users controller

Then add actions that will handle logging in and sign up to your UsersController. Open app/controllers/users_controller.rb and add following line to the controller class:

openid_login({ :openid_opts => { :model => User } })

Create OpenID login page

With current version of Hobo it’s impossible to include taglibs in gems (probably it’ll be possible when next version of Hobo comes out), so you will need  to change some pages manually. Create app/views/users/openid_login.dryml with following content:

<login-page>
  <form:>

    <labelled-item-list>

      <labelled-item>
        <item-label>OpenID</item-label>
        <input type="text" name="login" id="login" class="string"/>
      </labelled-item>

      <labelled-item if="&Hobo::User.default_user_model.column_names.include?('remember_token')">
        <item-label class="field-label">Remember me:</item-label>
        <input type="checkbox" name="remember_me" id="remember-me"/>
      </labelled-item>

    </labelled-item-list>

    <set user="&Hobo::User.default_user_model"/>

    <div class="actions">
      <submit label='Log in'/>
    </div>

  </form:>
</login-page>

Add links to OpenID login page on login and signup pages

Create app/views/users/signup.dryml with content

<signup-page>
  <append-body:>
    Or <a href="&openid_login_users_path">sign up using OpenID</a>.
  </append-body:>
</signup-page>

and app/views/users/login.dryml with content

<login-page>
  <append-body:>
    Or <a href="&openid_login_users_path">log in using OpenID</a>.
  </append-body:>
</login-page>

Create routes

Add this lines to config/routes.rb:

map.openid_login_users 'users/openid_login', :controller => 'users', :action => 'openid_login', :conditions => {:method => :get}
map.complete_openid_users 'users/complete_openid', :controller => 'users', :action => 'complete_openid', :conditions => {:method => :get}

Permalink Leave a Comment

Recruiters web application – please help testing

2010/08/03 at 7:21 pm (2010, GSoC 2010, Hobo, Planet Gentoo, Programming, Ruby on Rails, WebApplication)

Hello,
please help testing web application I’m developing for Gentoo Recruiters team.

Demo

Here is an instance of the application you can use for testing. If you do please remember a few things:

  • Don’t use your real email. There is no need to. There is no point to.
  • This instance can not send email notifications.
  • I will probably wipe its database from time to time so don’t put anything you don’t want deleted there.

Sources

If you want to read sources or run your own instance of the application you can obtain sources of the application from git repository on overlays.gentoo.org. When running your own instance of application remember a few things:

  • If you start application in ‘development’ mode it will be incredibly slow. You will be able to choose user from drop down list instead of logging in.
  • It’s tested for PostgreSQL and MySQL, probably will work with SQLite.

To get started do following:

git clone git://git.overlays.gentoo.org/proj/recruiting-webapp.git
cd recruiting-webapp
rake prepare:config db=mysql # you can use db=sqlite3 or db=postgres
nano config/config.yml # fill in usernames, passwords and database names
rake db:schema:load
rake gems:install # or `gem install hobo bluecloth`
./script/server -e production

then wait a few second for server to start (at my machine it takes about 10s) and visit 127.0.0.1:3000 .

Permalink 1 Comment

Weekly report #2 – middle of second iteration

2010/06/01 at 1:27 pm (GSoC 2010, Hobo, Planet Gentoo, Programming, Ruby on Rails, WebApplication)

Second iteration is a bit longer then the first one – it’s two weeks long. The demo was not updated (I’ll update it after iteration), work is going better this time – it takes about as much time as I predicted. Last week I completed a few tasks:

I cleaned code up after first iteration. I removed a broken answers counter (together with whole answers index which was useless), rewrote some functions to do filtering in SQL query not in Ruby after fetching results and fixed broken permissions.

I added seed data so you can start testing application easily and added instructions on how to get it running to README file.

I moved to shoulda to make some tests cleaner. I wrote and started using methods that set many permissions to avoid code duplication.

I make use of yeban’s work and replaced email+password login with OpenID login. If you want to use OpenID with Hobo you can use updated version of plugin from here.

I also upgraded the way answers are shown (now you can see question you are answering/ you answered) and added support for reference answers.

Permalink Leave a Comment

Weekly report #1 – after first week of work

2010/05/25 at 11:23 am (GSoC 2010, Hobo, Planet Gentoo, Programming, Ruby on Rails, WebApplication)

I think it’s about time I should write what I’m doing: web application for Gentoo Recruiters team. I’m doing it using Ruby on Rails with Hobo.

I finished my first week of work. This week’s goal was to get something basic working. This week I’ve completed a few tasks:

Setting up hobo project. It was pretty basic. I created new hobo application and created .gitignore file.

Roles for users. User can be recruit, mentor or recruiter or guest. I initially planned to use lifecycle to do it but Hobo allows only users in active state to log in. I made a separate model for role. After that and I noticed Hobo Enum Strings and replaced my Role model with HoboFields::EnumString.for(:recruit, :mentor, :recruiter) . Recruiters (an only recruiters) can be administrators. Administrators can do some things nobody else can.

Creating new questions. Recruiters can create questions and question categories (which is wrong – only administrators should be allowed to do that). Each question belongs to one category.

Answering questions. Any user logged in can create an answer. Every answer belongs to a question and is owned by user who created it. Recruiter can give user categories of questions. Users should answer all questions in categories they were assigned. Users can see all questions in categories they were assigned, all questions they answered (including those from other categories) and all questions in categories they were assigned, but they didn’t answer. In all questions listings answered questions are marked.

Viewing recruit answers. Registered user belongs to mentor (another user with role mentor or recruiter). Mentors can view answers of users they are mentoring. They can see:

  • Answers given by each user they are mentoring.
  • All answers given by all users they are mentoring.
  • All answers for questions in each category, given by all users they are mentor.

Demo. I put application on Heroku.

Finally a few links:

  • Working demo of my work on Heroku.
  • Git repository with my project on overlays.gentoo.org. Accepted commits go there. Once a commit went there you can expect it to stay there.
  • Git repository with my project on github. Commits there get edited a lot before they are pushed to repository on overlays.gentoo.org.

Permalink Leave a Comment

Creation of owned model

2010/05/10 at 6:53 pm (Hobo, Programming, Ruby on Rails, WebApplication)

I didn’t use owner actions because they are designed to take owner as parameter and I want current_user to always be owner of created object. Solution for that is quite simple. Luckily hobo_new takes a parameter – a record to be created.
def new
hobo_new Friend.new(:owner => current_user)
end

Does exactly what I needed.

Permalink Leave a Comment

Hobo permissions

2010/05/10 at 1:06 am (Hobo, Programming, Ruby on Rails)

I didn’t actually code anything today, but I remembered that I make owner readonly attribute and never shown attribute. If I understand how those two work my permission system will be doing what I want.

Permalink Leave a Comment

Modules

2010/05/09 at 1:12 am (Hobo, Programming, Ruby on Rails, WebApplication)

Today I noticed duplication in my models (two models were sharing most of their code and I was about to make a third really similar to them). Instead of making a third model I decided to get rid of duplication.

First I moved permissions to a module and it was easy. After that I wasted some time trying to move lifecycle to module, only to realize that it’s possible but ugly and tricky. I realized I was abusing lifecycles(but I liked it ;) ) and decided to use something else.

I wanted some actions available used two things only to owner and there are two things in Hobo that have names suggesting they are the right things to use for that: permissions and owner actions. I abandoned lifecycles and wrote clean, 36 lines short OwnedModel module. I’m not completely satisfied with it yet because:

  1. I use owner, but I don’t validate presence of one. It’s little problem I’ll fix it with Module::included callback in five minutes.
  2. I can’t get edit and view permissions right. Edit and view must be permitted when creating new record. But when creating new record it’s owner gets changed. So I need to allow viewing records after changing owner. And I’m a bit worried it may be exploited.

But it’s enough for now.

Permalink Leave a Comment

Hobo Lifecycles

2010/05/06 at 9:09 pm (Hobo, Programming, Ruby on Rails, WebApplication)

Actually I discovered Hobo lifecycles a few days ago but they are a great thing. I knew they exist for some time now but I didn’t realize how common lifecycles are. Hobo manual entry on lifecycles uses example of friendship invitation. It’s a good example because it gives opportunity to show most of the lifecycles features. However I got impression lifecycles are for doing things that are at least a bit complex. But they’re not :)

Before my code snippet a word of explanation: “friends” in my app are not friends like on social networking sites (other users that you know or pretend to know). These are more like contacts in address book (you collect some data about them).

My first Hobo lifecycle has one state, one creator and three transitions. I’m not sure if it is proper use of lifecycles or example of abusing (note: now I think it was abusing) them but here it is:

lifecycle do
state :existing

create :new_friend, :params => [:name, :email, :balance], :become => :existing,
:available_to => “User”, :user_becomes => :owner

transition :remove, {:existing => :destroy}, :available_to => :owner

transition :change, {:existing => :existing}, :params => [:name, :email, :balance],
:available_to => :owner

end

No much here, huh? Just creating, editing and editing of “friend”… But it does one more thing: it handles ownership with even less typing then Hobo Permissions.

First a word of explanation: “friends” in my app  are not friends like on social networking sites (other users that you know). These are more like contacts in addressbook (you collect some data about them).

Permalink Leave a Comment

Follow

Get every new post delivered to your Inbox.