Users using the Tequila login are invited to migrate to gitlab.epfl.ch. This instance will close for Tequila users by May 2020.

Commit 0185a362 authored by Florian Vessaz's avatar Florian Vessaz

Group and sort members by date on subscription page

parent e9d5a2c0
......@@ -635,6 +635,17 @@ C<< $member->subscription $ts >>
Set the UNIX timestamp corresponding to when the member last payed his
subscription. (Number of seconds since 1st January 1970.)
C<< $member->subscription_active >>
Return true if the member subscription has not expired yet.
C<< $member->subscription_expire >>
Return the UNIX timestamp corresponding to the expiration of the member's
subsciption. Subscriptions expire on 1st March of a given year unless the
subscription was payed after the 1st October of the previous year.
C<< $member->subscription_expire_as_string >>
Return the date when the subscription of the member expires.
=cut
sub subscription_as_string {
......@@ -651,41 +662,67 @@ sub subscription {
return $self->{gnugenMemberSubscriptionPayedDate};
}
sub subscription_expire {
my ($self) = @_;
my ($sec,$min,$hour,$mday,$mon,$year) = localtime($self->subscription);
$year += 1 if ($mon >= 9);
$year += 1;
return POSIX::mktime(0, 0, 12, 1, 2, $year);
}
sub subscription_expire_as_string {
my ($self) = @_;
my $ts = $self->subscription_expire;
return POSIX::strftime("%Y-%m-%d", localtime $ts);
}
sub subscription_active {
my ($self) = @_;
return time < $self->subscription_expire;
}
=head2 UNIX account
C<< $member->shadow_expire >>
Return the UNIX timestamp when the UNIX account of the member will expire.
C<< $member->shadow_expire_as_string >>
Return the date when the UNIX account of the member will expire in a
human-readable format.
C<< $member->shadow_expire_update >>
Set the UNIX account expiration date according to the ToS acceptation and when
the member payed his subscription last. Accounts expire on 1st March of a given
year unless the subscription was payed after the 1st October of the previous
year.
Set the UNIX account expiration date according to the ToS acceptation and the
date of expiration of the member's subscription.
C<< $member->active >>
Return true if the member accepted the ToS and his UNIX account has not expired.
=cut
sub shadow_expire_as_string {
sub shadow_expire {
my ($self) = @_;
if (defined $self->{shadowExpire}) {
my $ts = $self->{shadowExpire} * 86400;
return $self->{shadowExpire} * 86400;
} else {
return 0;
}
};
sub shadow_expire_as_string {
my ($self) = @_;
my $ts = $self->shadow_expire;
if ($ts > 0) {
return POSIX::strftime("%Y-%m-%d", localtime $ts);
} else {
return 'never';
}
}
};
sub shadow_expire_update {
my ($self) = @_;
my $ts = $SHADOW_EXPIRE_DISABLED;
if ($self->tos_accepted) {
my ($sec,$min,$hour,$mday,$mon,$year) = localtime($self->subscription);
$year += 1 if ($mon >= 9);
$year += 1;
$ts = int(POSIX::mktime(0, 0, 12, 1, 2, $year) / 86400);
$ts = int($self->subscription_expire / 86400);
}
if ($ts != $self->{shadowExpire}) {
$self->_modify(shadowExpire => $ts);
......
......@@ -256,12 +256,27 @@ get '/subscriptions' => sub {
return "Unauthorized";
}
my $members = GnuGeneration::Member->all_members;
my @members;
push @members, $members->{$_} foreach (sort keys(%$members));
my @members = sort {
($b->subscription_expire <=> $a->subscription_expire)
or ($b->subscription <=> $a->subscription)
or ($a->username cmp $b->username)
} values(%{GnuGeneration::Member->all_members});
my %active_members_by_year;
my %inactive_members_by_year;
foreach my $member (@members) {
my $year = POSIX::strftime("%Y", localtime $member->subscription_expire);
if ($member->subscription_active) {
push @{$active_members_by_year{$year}}, $member;
} else {
push @{$inactive_members_by_year{$year}}, $member;
}
}
template 'subscriptions', {
'members' => \@members,
'active_members_by_year' => \%active_members_by_year,
'inactive_members_by_year' => \%inactive_members_by_year,
};
};
......
......@@ -21,8 +21,12 @@ color: #000;
}
table {
border-spacing: 0px;
border-collapse: collapse;
border-spacing: 0px;
border-collapse: collapse;
}
table th {
text-align: left;
}
tr {
......@@ -139,6 +143,10 @@ input[type=text][disabled], input[type=password][disabled], select[disabled] {
}
}
table.subscriptions_table {
min-width: 100%;
}
table.big_table tr,
table.subscriptions_table tr {
vertical-align: middle;
......
<% block table_row %>
<tr>
<td><% member.username %></td>
<td><% member.firstName %></td>
<td><% member.lastName %></td>
<td><% member.subscription_expire_as_string %></td>
<td>
<input type="text" name="<% member.username %>-date"
value="<% member.subscription_as_string %>"/>
</td>
<td>
<input type="checkbox" name="<% member.username %>-now"/>
</td>
</tr>
<% end %>
<% block subscription_table %>
<table class="subscriptions_table">
<tr>
<th>Username</th>
<th>First name</th>
<th>Last name</th>
<th>Until</th>
<th>Payed on</th>
<th>Pay now?</th>
</tr>
<% foreach member in members %>
<% include table_row member=member %>
<% end %>
</table>
<% end %>
<% block subscriptions_by_year %>
<% foreach year in members_by_year.keys.sort.reverse %>
<h3><% year %> (<%members_by_year.item(year).size %>)</h3>
<% include subscription_table members=members_by_year.item(year) %>
<% end %>
<% end %>
<form method="POST" action="">
<h1>Subscriptions</h1>
......@@ -12,29 +51,11 @@
form is submitted.
</p>
<table class="subscriptions_table">
<tr>
<th>Username</th>
<th>First name</th>
<th>Last name</th>
<th>Payed on</th>
<th>Pay now?</th>
</tr>
<% foreach member in members %>
<tr>
<td><% member.username %></td>
<td><% member.firstName %></td>
<td><% member.lastName %></td>
<td>
<input type="text" name="<% member.username %>-date"
value="<% member.subscription_as_string %>"/>
</td>
<td>
<input type="checkbox" name="<% member.username %>-now"/>
</td>
</tr>
<% end %>
</table>
<h2>Active members</h2>
<% include subscriptions_by_year members_by_year=active_members_by_year %>
<h2>Old members</h2>
<% include subscriptions_by_year members_by_year=inactive_members_by_year %>
<p>
Be responsible: it is not fun to fix the dates in the LDAP if you mess up.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment