20 Commits

Author SHA1 Message Date
46a7345ce9 Merge pull request 'Add main navigation bar' (#20) from feature/main_nav into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #20
2020-12-29 10:04:42 +00:00
e12d02a988 Fix spec
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Content changed
2020-12-29 11:02:24 +01:00
5e8618f25a Merge pull request 'Add admin layout with admin navigation' (#21) from feature/admin_layout into feature/main_nav
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing
Reviewed-on: #21
2020-12-29 09:58:57 +00:00
2bdf08a523 Add admin layout with admin navigation
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
And remove the hacky link list from the dashboard.
2020-12-28 09:32:04 +01:00
9ddd36c414 Add missing section markup
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2020-12-27 14:21:16 +01:00
9372ea7343 Add small-screen layout for main navigation 2020-12-27 14:14:53 +01:00
c62ce00184 Add main navigation bar
Make donations and invitations accessible to everyone
2020-12-27 14:03:40 +01:00
4d8cd740ba Argh
All checks were successful
continuous-integration/drone/push Build is passing
2020-12-22 17:15:46 +01:00
9858572a2f Remove useless bundler version requirement
All checks were successful
continuous-integration/drone/push Build is passing
2020-12-22 17:03:14 +01:00
51edf55ae9 Use zerotier for connecting to postgres
All checks were successful
continuous-integration/drone/push Build is passing
2020-12-22 12:24:18 +01:00
75485ce8e9 Merge pull request 'Update postgres master host' (#19) from chore/update_postgres_host into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #19
2020-12-22 10:42:51 +00:00
fcbfcc4007 Update postgres master host
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2020-12-22 11:41:40 +01:00
cdcb7b3aef Update README
All checks were successful
continuous-integration/drone/push Build is passing
2020-12-21 15:49:58 +01:00
bcf5172956 Merge pull request 'Add basic donation records' (#18) from feature/donation_records into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #18
2020-12-21 14:46:50 +00:00
26c6c5a3b2 Nullify donation owners when related record destroyed
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2020-12-21 13:59:46 +01:00
4a65573934 Format numbers on admin donations page
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
And fix the wrong unit display in the user donations list.
2020-12-19 14:59:16 +01:00
5e2d5c3b28 Add paid_at date to donations
All checks were successful
continuous-integration/drone/push Build is passing
2020-12-19 13:28:47 +01:00
2f70bae523 Format and style user donations 2020-12-19 13:16:04 +01:00
40f3e8327a Basic donation records
Adds donation model/table and basic manual management in the admin
panel, as well as basic listing of users' own donations.
2020-12-17 21:56:51 +01:00
f3d6e29e4e Remove time from used invitations list
Date is enough.
2020-12-17 17:02:30 +01:00
47 changed files with 643 additions and 46 deletions

View File

@@ -252,6 +252,7 @@ GEM
PLATFORMS
ruby
x86_64-linux
DEPENDENCIES
bootsnap (>= 1.4.2)
@@ -284,4 +285,4 @@ DEPENDENCIES
webpacker (~> 4.0)
BUNDLED WITH
2.0.2
2.2.2

View File

@@ -11,7 +11,7 @@ credentials, invites, donations, etc..
* [x] Log in with admin permissions
* [x] View LDAP users as admin
* [x] Sign up for a new account via invitation
* [ ] List my donations
* [x] List my donations
* [ ] Invite new users from your account
* [ ] Sign up for a new account by donating upfront
* [ ] Sign up for a new account via proving contributions (via cryptographic signature)

View File

@@ -0,0 +1,13 @@
$content-width: 800px;
$content-max-width: 100%;
$text-color-body: #222;
$text-color-discreet: #888;
$background-color-notice: #efffc4;
$background-color-alert: #fff4c2;
$color-blue: #0d4f99;
$color-purple: #8955a0;
$color-red-bright: #c00;
$color-red-dark: #990c0e;

View File

@@ -0,0 +1,22 @@
@import "variables";
body#admin-panel {
#wrapper {
> header {
background: $color-red-bright;
background: linear-gradient(35deg, $color-purple 0, $color-red-dark 100%);
}
}
#main-nav {
ul {
li {
a {
&.active {
border-bottom: 2px solid $color-red-bright;
}
}
}
}
}
}

View File

@@ -0,0 +1,40 @@
ul.donations {
list-style: none;
li {
margin-bottom: 2rem;
display: grid;
grid-row-gap: 0.5rem;
grid-column-gap: 2rem;
grid-template-columns: 1fr 1fr;
grid-template-areas:
"date amount-btc"
"public-name amounts-fiat";
h3 {
grid-area: "date";
margin-bottom: 0;
}
p {
margin-bottom: 0;
&.amount-btc {
grid-area: amount-btc;
text-align: right;
font-family: monospace;
font-size: 1.25rem;
}
&.amounts-fiat {
grid-area: amounts-fiat;
text-align: right;
font-family: monospace;
font-size: 0.85rem;
color: #888;
}
&.public-name {
grid-area: public-name;
}
}
}
}

View File

@@ -1,3 +1,5 @@
@import "variables";
@font-face {
font-family: 'Raleway';
src: url('/fonts/raleway-light.woff') format('woff2');
@@ -8,6 +10,7 @@
body {
font-family: "Open Sans", Helvetica, Arial, sans-serif;
font-weight: 400;
color: $text-color-body;
}
h1, h2, h3 {

View File

@@ -22,10 +22,6 @@ form {
color: #bc0101;
}
.actions {
margin-top: 2rem;
}
.accept-terms {
margin-top: 2rem;
font-size: 0.85rem;

View File

@@ -1,11 +1,6 @@
@import "variables";
@import "mediaqueries";
$content-width: 800px;
$content-max-width: 100%;
body {
}
#wrapper {
width: 100%;
text-align: center;
@@ -14,8 +9,8 @@ body {
margin: 0 auto;
padding: 4rem 0;
text-align: center;
background: #0d4f99;
background: linear-gradient(35deg, #8955a0 0, #0d4f99 100%);
background: $color-blue;
background: linear-gradient(35deg, $color-purple 0, $color-blue 100%);
@include media-max(small) {
padding: 3rem 0;
@@ -77,18 +72,18 @@ body {
padding: 2rem 0;
&.notice {
background: #efffc4;
background: $background-color-notice;
}
&.alert {
background: #fff4c2;
background: $background-color-alert;
}
}
main {
width: $content-width;
max-width: $content-max-width;
margin: 4rem auto;
margin: 4rem auto 6rem auto;
text-align: left;
@include media-max(medium) {
@@ -135,14 +130,18 @@ main {
section {
border-bottom: 1px dotted #ccc;
padding-bottom: 4rem;
margin-bottom: 4rem;
padding-bottom: 3rem;
margin-bottom: 3rem;
@include media-max(small) {
padding-bottom: 3rem;
margin-bottom: 3rem;
}
}
.actions {
margin-top: 2rem;
}
}
.grid {
@@ -165,9 +164,13 @@ main {
.grid-item {
p {
color: #888;
color: $text-color-discreet;
font-size: 0.85rem;
}
}
}
}
.text-centered {
text-align: center;
}

View File

@@ -0,0 +1,51 @@
@import "variables";
@import "mediaqueries";
#main-nav {
width: 100%;
text-align: center;
background-color: #efefef;
.wrapper {
width: $content-width;
max-width: $content-max-width;
margin: 0 auto;
}
ul {
@include media-max(large) {
display: grid;
grid-template-columns: repeat(1fr);
grid-template-columns: 1fr 1fr 1fr;
}
li {
@include media-min(large) {
display: inline;
}
@include media-max(large) {
display: block;
}
a {
display: inline-block;
padding: 1.5rem 2rem;
text-decoration: none;
color: $text-color-discreet;
@include media-max(large) {
display: block;
text-align: center;
padding-left: 0;
padding-right: 0;
}
&.active {
color: $text-color-body;
border-bottom: 2px solid #ffd000;
}
}
}
}
}

View File

@@ -3,4 +3,6 @@ class Admin::BaseController < ApplicationController
before_action :authenticate_user!
before_action :authorize_admin
layout "admin"
end

View File

@@ -1,4 +1,5 @@
class Admin::DashboardController < Admin::BaseController
def index
@current_section = :dashboard
end
end

View File

@@ -0,0 +1,79 @@
class Admin::DonationsController < Admin::BaseController
before_action :set_donation, only: [:show, :edit, :update, :destroy]
before_action :set_current_section, only: [:index, :show, :new, :edit]
# GET /donations
# GET /donations.json
def index
@donations = Donation.all
end
# GET /donations/1
# GET /donations/1.json
def show
end
# GET /donations/new
def new
@donation = Donation.new
end
# GET /donations/1/edit
def edit
end
# POST /donations
# POST /donations.json
def create
@donation = Donation.new(donation_params)
respond_to do |format|
if @donation.save
format.html { redirect_to admin_donation_url(@donation), notice: 'Donation was successfully created.' }
format.json { render :show, status: :created, location: @donation }
else
format.html { render :new }
format.json { render json: @donation.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /donations/1
# PATCH/PUT /donations/1.json
def update
respond_to do |format|
if @donation.update(donation_params)
format.html { redirect_to admin_donation_url(@donation), notice: 'Donation was successfully updated.' }
format.json { render :show, status: :ok, location: @donation }
else
format.html { render :edit }
format.json { render json: @donation.errors, status: :unprocessable_entity }
end
end
end
# DELETE /donations/1
# DELETE /donations/1.json
def destroy
@donation.destroy
respond_to do |format|
format.html { redirect_to admin_donations_url, notice: 'Donation was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_donation
@donation = Donation.find(params[:id])
end
# Only allow a list of trusted parameters through.
def donation_params
params.require(:donation).permit(:user_id, :amount_sats, :amount_eur, :amount_usd, :public_name, :paid_at)
end
def set_current_section
@current_section = :donations
end
end

View File

@@ -1,4 +1,6 @@
class Admin::LdapUsersController < Admin::BaseController
before_action :set_current_section
def index
attributes = %w{dn cn uid mail admin}
filter = Net::LDAP::Filter.eq("uid", "*")
@@ -38,4 +40,8 @@ class Admin::LdapUsersController < Admin::BaseController
def ldap_config
ldap_config ||= YAML.load(ERB.new(File.read("#{Rails.root}/config/ldap.yml")).result)[Rails.env]
end
def set_current_section
@current_section = :ldap_users
end
end

View File

@@ -2,5 +2,6 @@ class DashboardController < ApplicationController
before_action :require_user_signed_in
def index
@current_section = :dashboard
end
end

View File

@@ -0,0 +1,10 @@
class DonationsController < ApplicationController
before_action :require_user_signed_in
# GET /donations
# GET /donations.json
def index
@donations = current_user.donations.completed
@current_section = :contributions
end
end

View File

@@ -8,6 +8,7 @@ class InvitationsController < ApplicationController
def index
@invitations_unused = current_user.invitations.unused
@invitations_used = current_user.invitations.used
@current_section = :invitations
end
# GET /invitations/a-random-invitation-token

View File

@@ -1,2 +1,5 @@
module ApplicationHelper
def sats_to_btc(sats)
sats.to_f / 100000000
end
end

View File

@@ -0,0 +1,2 @@
module DonationsHelper
end

13
app/models/donation.rb Normal file
View File

@@ -0,0 +1,13 @@
class Donation < ApplicationRecord
# Relations
belongs_to :user
# Validations
validates_presence_of :amount_sats
# Hooks
# TODO before_create :store_fiat_value
#Scopes
scope :completed, -> { where.not(paid_at: nil) }
end

View File

@@ -3,6 +3,7 @@ class User < ApplicationRecord
# Relations
has_many :invitations, dependent: :destroy
has_many :donations, dependent: :nullify
validates_uniqueness_of :cn
validates_length_of :cn, :minimum => 3

View File

@@ -1,7 +1,3 @@
<h2>Admin Panel</h2>
<p>
Ohai there, admin human.
</p>
<p>
<%= link_to 'LDAP users', admin_ldap_users_path %>
<p class="text-centered">
With great power comes great responsibility.
</p>

View File

@@ -0,0 +1,2 @@
json.extract! donation, :id, :user_id, :amount_sats, :amount_eur, :amount_usd, :public_name, :created_at, :updated_at
json.url donation_url(donation, format: :json)

View File

@@ -0,0 +1,60 @@
<%= form_with(url: url, model: donation, local: true) do |form| %>
<% if donation.errors.any? %>
<div id="error_explanation">
<h3><%= pluralize(donation.errors.count, "error") %> prohibited this donation from being saved:</h3>
<ul>
<% donation.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<p>
<%= form.label :user_id %>
<%= form.collection_select :user_id, User.where(ou: "kosmos.org").order(:cn), :id, :cn %>
</p>
</div>
<div class="field">
<p>
<%= form.label :amount_sats, "Amount BTC (sats)" %>
<%= form.number_field :amount_sats %>
</p>
</div>
<div class="field">
<p>
<%= form.label :amount_eur, "Amount EUR (cents)" %>
<%= form.number_field :amount_eur %>
</p>
</div>
<div class="field">
<p>
<%= form.label :amount_usd, "Amount USD (cents)"%>
<%= form.number_field :amount_usd %>
</p>
</div>
<div class="field">
<p>
<%= form.label :public_name %>
<%= form.text_field :public_name %>
</p>
</div>
<div class="field">
<p>
<%= form.label :paid_at %>
<%= form.text_field :paid_at %>
</p>
</div>
<div class="actions">
<p>
<%= form.submit %>
</p>
</div>
<% end %>

View File

@@ -0,0 +1,8 @@
<h2>Editing Donation</h2>
<%= render 'form', donation: @donation, url: admin_donation_path(@donation) %>
<p class="actions">
<%= link_to 'Show', admin_donation_path(@donation) %> |
<%= link_to 'Back', admin_donations_path %>
<p>

View File

@@ -0,0 +1,41 @@
<h2>Donations</h2>
<% if @donations.any? %>
<table>
<thead>
<tr>
<th>User</th>
<th>Amount BTC</th>
<th>in EUR</th>
<th>in USD</th>
<th>Public name</th>
<th>Date</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @donations.each do |donation| %>
<tr>
<td><%= donation.user.cn %></td>
<td><%= sats_to_btc donation.amount_sats %> BTC</td>
<td><%= number_to_currency donation.amount_eur / 100, unit: "" %></td>
<td><%= number_to_currency donation.amount_usd / 100, unit: "" %></td>
<td><%= donation.public_name %></td>
<td><%= donation.paid_at ? donation.paid_at.strftime("%Y-%m-%d") : "" %></td>
<td><%= link_to 'Show', admin_donation_path(donation) %></td>
<td><%= link_to 'Edit', edit_admin_donation_path(donation) %></td>
<td><%= link_to 'Destroy', admin_donation_path(donation), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p>
No donations yet.
</p>
<% end %>
<p class="actions">
<%= link_to 'Record an out-of-system donation', new_admin_donation_path %>
</p>

View File

@@ -0,0 +1 @@
json.array! @donations, partial: "donations/donation", as: :donation

View File

@@ -0,0 +1,7 @@
<h2>New Donation</h2>
<%= render 'form', donation: @donation, url: admin_donations_path %>
<p class="actions">
<%= link_to 'Back', admin_donations_path %>
</p>

View File

@@ -0,0 +1,34 @@
<p id="notice"><%= notice %></p>
<p>
<strong>User:</strong>
<%= @donation.user_id %>
</p>
<p>
<strong>Amount sats:</strong>
<%= @donation.amount_sats %>
</p>
<p>
<strong>Amount eur:</strong>
<%= @donation.amount_eur %>
</p>
<p>
<strong>Amount usd:</strong>
<%= @donation.amount_usd %>
</p>
<p>
<strong>Public name:</strong>
<%= @donation.public_name %>
</p>
<p>
<strong>Date:</strong>
<%= @donation.paid_at %>
</p>
<%= link_to 'Edit', edit_admin_donation_path(@donation) %> |
<%= link_to 'Back', admin_donations_path %>

View File

@@ -0,0 +1 @@
json.partial! "donations/donation", donation: @donation

View File

@@ -0,0 +1,38 @@
<section>
<h2>Donations</h2>
<p>
Your financial contributions to the development and
upkeep of Kosmos software and services.
</p>
</section>
<section>
<% if @donations.any? %>
<ul class="donations">
<% @donations.each do |donation| %>
<li>
<h3>
<%= donation.paid_at.strftime("%B %d, %Y") %>
</h3>
<p class="amount-btc">
<%= sats_to_btc donation.amount_sats %> BTC
</p>
<p class="amounts-fiat">
(~ <%= number_to_currency donation.amount_eur / 100, unit: "" %> EUR)
</p>
<p class="public-name">
<% if donation.public_name.present? %>
Public name: <%= donation.public_name %>
<% else %>
Anonymous
<% end %>
</p>
</li>
<% end %>
</ul>
<% else %>
<p>
No donations to show.
</p>
<% end %>
</section>

View File

@@ -0,0 +1 @@
json.array! @donations, partial: "donations/donation", as: :donation

View File

@@ -24,23 +24,25 @@
</section>
<% if @invitations_used.any? %>
<h3>Accepted Invitations</h3>
<table>
<thead>
<tr>
<th>URL</th>
<th>Used at</th>
<th>Invited user</th>
</tr>
</thead>
<tbody>
<% @invitations_used.each do |invitation| %>
<section>
<h3>Accepted Invitations</h3>
<table>
<thead>
<tr>
<td><%= invitation_url(invitation.token) %></td>
<td><%= invitation.used_at %></td>
<td><%= User.find(invitation.invited_user_id).address %></td>
<th>URL</th>
<th>Accepted</th>
<th>Invited user</th>
</tr>
<% end %>
</tbody>
</table>
</thead>
<tbody>
<% @invitations_used.each do |invitation| %>
<tr>
<td class="overflow-ellipsis"><%= invitation_url(invitation.token) %></td>
<td><%= invitation.used_at.strftime("%Y-%m-%d") %></td>
<td><%= User.find(invitation.invited_user_id).address %></td>
</tr>
<% end %>
</tbody>
</table>
</section>
<% end %>

View File

@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<head>
<title>Admin Panel | Kosmos Accounts</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<meta name="viewport" content="width=device-width, initial-scale=1">
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body id="admin-panel">
<div id="wrapper">
<header>
<h1>
<span class ="project-name">Kosmos</span>
<span class ="site-name">Akkounts</span>
<span class="beta"><span class="bolt">⚡</span> beta</span>
</h1>
<% if user_signed_in? %>
<p class="current-user">
Signed in as <strong><%= current_user.cn %>@kosmos.org</strong>.
<%= link_to "Log out", destroy_user_session_path, method: :delete %>
</p>
<% end %>
</header>
<% if user_signed_in? && current_user.confirmed? %>
<%= render partial: 'shared/admin_nav' %>
<% end %>
<% flash.each do |type, msg| %>
<div class="flash-msg <%= type %>">
<p><%= msg %></p>
</div>
<% end %>
<main>
<%= yield %>
</main>
</div>
</body>
</html>

View File

@@ -27,6 +27,10 @@
<% end %>
</header>
<% if user_signed_in? && current_user.confirmed? %>
<%= render partial: 'shared/main_nav' %>
<% end %>
<% flash.each do |type, msg| %>
<div class="flash-msg <%= type %>">
<p><%= msg %></p>

View File

@@ -0,0 +1,18 @@
<nav id="main-nav">
<div class="wrapper">
<ul class="pages">
<li>
<%= link_to "Dashboard", admin_root_path,
class: @current_section == :dashboard ? "active" : nil %>
</li>
<li>
<%= link_to "Donations", admin_donations_path,
class: @current_section == :donations ? "active" : nil %>
</li>
<li>
<%= link_to "LDAP Users", admin_ldap_users_path,
class: @current_section == :ldap_users ? "active" : nil %>
</li>
</ul>
</div>
</nav>

View File

@@ -0,0 +1,18 @@
<nav id="main-nav">
<div class="wrapper">
<ul class="pages">
<li>
<%= link_to "Services", root_path,
class: @current_section == :dashboard ? "active" : nil %>
</li>
<li>
<%= link_to "Donations", donations_path,
class: @current_section == :contributions ? "active" : nil %>
</li>
<li>
<%= link_to "Invitations", invitations_path,
class: @current_section == :invitations ? "active" : nil %>
</li>
</ul>
</div>
</nav>

View File

@@ -1 +1 @@
LWyKwPZq9Kd97rn/7+q3MEkh7kITScDMHD3JvVuaV3A4YIHJHU+460k+PaEGlsH1xkbuClGiAb57rk1XLyDnmVGtbSueYOtinkw6kar8ZfKWZob061LwGjpMVRQkS49TjCUZlqCFrXeKxlH03mXWBnqAj9RUIPrm7eibb3c7qmJFglR1380RSVsfZnp8A3QwGm4Wh9OWtpUa6P2lne0jQsOuSe8ur3DUF0LplzS4CbkMxAUDOom+pXB13AlxOH9NQE7F4dsYHugHkh1tG3r3ER3xAUD/9Kn6UZZP7BnwUs3zqhoZdULRpRgA5dK7ueTIAnO/jtJDF4562VS8ECo7AnNoVxNe8/mBMFIOUfqg+db/72N2pIk3r4lK7Uzm/4jJ5/99ItnQjHQPcApiwZXIr3OyDLUvq5+d0UVmAMXdwcAjvctVQXFx5imG149Y0ISHKWVm1ca37aAspxWPU+CIj8/HW0yEpjp3vhwDUbjCaZeAPm8UQC14MxZwSK3N+EUSQXdltiweFynabDB7zGGQsjMM8LwMtyo9bTBzJA78Cl96MDyd20i1zSF9ntLuKulwGm3oZowpbNuvo2anY6r9yBlDJBOEISbtXv2tLX4SqcM=--bRcsE4K/29XzyZat--+G3iQCLBqgSwLaQ+7+4YvA==
IUCQBycRu4CEN/PXSJGZNq3SHgrEnDZfPo2suTPBxLXqKk59+cZa5ID3CBXY+CNhCnV9gAhn2GTLm/kq6HNEGFsV6AmKh/rYy9YGqoS+vWrUdgecvqYQfEz0KsAzYn4iEJ4EoQYpJ3/Y6Cen9zzeq/h1OIkMuzsTiKIG4q09j5rWBIaUyHQe75OdE4Ik681xitAUcS3sBJzhnnar9LqiLvx9fgRlVqWNGG1eAl926apptsgv/VoQ81HmkY0Lt7UWSOWRL1D4FhvjQiAiwc9xwTeKNH/BWdMhoXqDmrMsvuIqwIYFrbE9X2oP7KJYu3Cch14qDN/1JEMd4dGuq9uHTXAKVK9M9sFHeEUoqtVTQw+Vp/cCCg4oVtTOOv5IPIrJc8LuOhRPE/Iu5N36OYsEV1+6KunZ/4Ys8309K94fUgOBltQ8V6Gky6OutnlaOhDBGSc8IVkzlPuBNrmOBYBzVl8r9VAu8hGonN4BI6Y+Aicrq/ZMH0P1gZnEsPKyRaoP2Pvx7wVIX27luWfGrV0i/fJG0qitlyZ7nCEtnw/6OXp2bIcHv+UiQEX4AYZO3XW3QNZjNeng6HVrSJlRK/vcWVEFHNZPKi4iRN6qXH0D7Q==--z6FJEn+mmxweg7jD--wwT5g/XEd+U9eBwqK234cQ==

View File

@@ -1,4 +1,5 @@
Rails.application.routes.draw do
resources :donations
devise_for :users
get 'welcome', to: 'welcome#index'
@@ -16,6 +17,7 @@ Rails.application.routes.draw do
namespace :admin do
root to: 'dashboard#index'
get 'ldap_users', to: 'ldap_users#index'
resources :donations
end
# Letter Opener (open "sent" emails in dev and staging)

View File

@@ -8,6 +8,7 @@ class CreateInvitations < ActiveRecord::Migration[6.0]
t.timestamps
end
add_index :invitations, :user_id
add_index :invitations, :invited_user_id
end

View File

@@ -0,0 +1,15 @@
class CreateDonations < ActiveRecord::Migration[6.0]
def change
create_table :donations do |t|
t.integer :user_id
t.integer :amount_sats
t.integer :amount_eur
t.integer :amount_usd
t.string :public_name
t.timestamps
end
add_index :donations, :user_id
end
end

View File

@@ -0,0 +1,5 @@
class AddPaidAtToDonations < ActiveRecord::Migration[6.0]
def change
add_column :donations, :paid_at, :datetime
end
end

View File

@@ -10,7 +10,19 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_11_30_132533) do
ActiveRecord::Schema.define(version: 2020_12_19_121808) do
create_table "donations", force: :cascade do |t|
t.integer "user_id"
t.integer "amount_sats"
t.integer "amount_eur"
t.integer "amount_usd"
t.string "public_name"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.datetime "paid_at"
t.index ["user_id"], name: "index_donations_on_user_id"
end
create_table "invitations", force: :cascade do |t|
t.string "token"

View File

@@ -0,0 +1,9 @@
FactoryBot.define do
factory :donation do
user_id { 1 }
amount_sats { 100000 }
amount_eur { 10 }
amount_usd { 13 }
public_name { nil }
end
end

View File

@@ -10,6 +10,6 @@ RSpec.describe 'Admin dashboard', type: :feature do
scenario 'View dashboard' do
visit admin_root_path
expect(page).to have_content('Admin Panel')
expect(page).to have_content('great power')
end
end

View File

@@ -0,0 +1,9 @@
require 'rails_helper'
describe ApplicationHelper do
describe "sats_to_btc" do
it "converts satoshis to BTC" do
expect(helper.sats_to_btc(120000000)).to eq(1.2)
end
end
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the DonationsHelper. For example:
#
# describe DonationsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe DonationsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Donation, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end