Git Product home page Git Product logo

garnet's Introduction

Garnet

Local Setup

$ git clone https://github.com/ga-dc/garnet
$ cd garnet
$ bundle
$ rake db:create
$ rake db:migrate
$ rake db:seed
$ rails s

current_user

It exists. See the application controller and helper.

Github Authentication

Setup

bundle exec figaro install

Register a Github application and update config/application.yml to look like this:

gh_client_id: "12345"
gh_client_secret: "67890"
gh_redirect_url: "http://localhost:3000/github/authenticate"

Github model

The Github model has an API method. To use it:

# Gets the current organization's repos
request = Github.new(ENV).api.repos

# Gets the current user's repos
request = Github.new(ENV, session[:access_token]).api.repos

It's built on the Octokit gem. For more information see the Octokit docs.

Methods of note

  • User.named: short for User.find_by(username: )

  • @user.role: returns a specific membership

  • @user.minions: returns all users of all groups of which the user is a member, who are not admins

  • Membership.in_role: returns a specific membership

  • Membership.bulk_create

  • @membership.observe(name, body): creates an observation for a non-admin with a particular name in that membership's group

  • @membership.minions: returns all other members of the group that are not admin

  • Group.bulk_create: creates a tree of groups (nested groups)

  • Group.named: short for Group.find_by(title: )

  • @group.subgroup_array: returns a single-level array of all subgroups nested under this group

  • @group.subgroup_tree: returns a nested hash of all subgroups nested under this group

  • @group.get_subgroups(key): for example, @group.get_subgroups("attendances"). Imagine there's an apostrophe at the end of subgroups.

  • @group.members: returns a hash of all group members' and submembers' submissions, observations, and attendances

Helpers of note

  • Application

    • color_of: turns an input number into its corresponding color (for color scales)
    • percent_of(collection, value): how many members of an AR collection are of a certain value
  • Group

    • breadcrumbs(group, user = nil): navigation breadcrumbs for a group (optionally with a user on the end)
    • subgroup_tree_html: nested <ul> of the current group and its subgroups

User stories

Github Auth

Users can sign up with or without Github.

If they sign up with Github, they cannot update their username, password, e-mail, etc. Every time they subsequently sign in, the Github API is polled for their most recent information, and the database is updated accordingly.

If they sign up without Github, they can update their username, password, e-mail, etc. Should they wish to later link Github to their account, they can click the "Link Github account" link, which will poll the database, rewrite their information in the Users table to use their Github username, email, etc. From there their account will behave as if they had originally signed up with Github.

Users with an admin membership to a group

  • Assignments and submissions
    • Create an assignment for the group
      • Automatically create incomplete submissions for all non-admin members of the group
    • Grade (update) a submission for the group
    • Read (but not create or update) all assignments for sub-groups
    • Read (but not create or update) all submissions for sub-groups
  • Groups and memberships
    • Create a sub-group within the group
    • Add admin memberships to the group
    • Add non-admin memberships to the group
    • Edit memberships of the group
  • Observations
    • Create an observation for a non-admin member of the group
    • Read (but not create or update) all observations for sub-groups

All users

  • User info
    • Change their password, username, and name
    • Authorize their account for Github API access
  • Groups
    • View all groups owners
  • Submissions
    • Complete a submission for an assignment (via update)
    • See submissions that they have completed
    • See submissions that have been assigned to (created for) them
  • Attendance
    • Mark that they have attended an event
    • See events they have attended
    • See events at which they are expected to attend

Student

=begin
if signed_in && gh_db && current_user.id == gh_db.id
  current_user
if signed_in && gh_db && current_user.id != gh_db.id
  "error: gh account already linked"
if signed_in && !gh_db
  current_user
if !signed_in && gh_db
  gh_db_user
if !signed_in && !gh_db
  User.new
=end

Deployment

When commits are pushed or merged via pull request to master on this repo, Travis clones the application, runs bundle exec rake to run tests specified in spec/.

If all tests pass, travis pushes to the production repo: [email protected]:garnet.git

This triggers a post-update hook, which pulls from GitHub's master branch and restarts unicorn, the application server.

garnet's People

Contributors

adambray avatar amaseda avatar andrewsunglaekim avatar ebirving avatar jshawl avatar jsm13 avatar nolds9 avatar robertakarobin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.