[vhffs-dev] [2181] merged panel home (almost empty for years) and group index |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 2181
Author: gradator
Date: 2012-05-08 02:03:19 +0200 (Tue, 08 May 2012)
Log Message:
-----------
merged panel home (almost empty for years) and group index
Modified Paths:
--------------
trunk/vhffs-api/src/Makefile.am
trunk/vhffs-api/src/Vhffs/Panel/Admin.pm
trunk/vhffs-api/src/Vhffs/Panel/Auth.pm
trunk/vhffs-api/src/Vhffs/Panel/Group.pm
trunk/vhffs-api/src/Vhffs/Panel/User.pm
trunk/vhffs-api/src/Vhffs/User.pm
trunk/vhffs-panel/index.pl
trunk/vhffs-panel/templates/Makefile.am
trunk/vhffs-panel/templates/group/index.tt
trunk/vhffs-panel/templates/misc/header.tt
Removed Paths:
-------------
trunk/vhffs-api/src/Vhffs/Panel/Home.pm
trunk/vhffs-panel/templates/misc/welcome.tt
Modified: trunk/vhffs-api/src/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Makefile.am 2012-05-07 21:54:23 UTC (rev 2180)
+++ trunk/vhffs-api/src/Makefile.am 2012-05-08 00:03:19 UTC (rev 2181)
@@ -31,7 +31,6 @@
Vhffs/Panel/Cvs.pm \
Vhffs/Panel/DNS.pm \
Vhffs/Panel/Group.pm \
- Vhffs/Panel/Home.pm \
Vhffs/Panel/Mail.pm \
Vhffs/Panel/MailingList.pm \
Vhffs/Panel/Broadcast.pm \
Modified: trunk/vhffs-api/src/Vhffs/Panel/Admin.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Admin.pm 2012-05-07 21:54:23 UTC (rev 2180)
+++ trunk/vhffs-api/src/Vhffs/Panel/Admin.pm 2012-05-08 00:03:19 UTC (rev 2181)
@@ -493,7 +493,7 @@
$panel->render('misc/message.tt', {
message => gettext( sprintf( 'Su successful with name %s' , $user->get_username) ),
- refresh_url => '?do=home'
+ refresh_url => '?do=groupindex'
});
return;
}
Modified: trunk/vhffs-api/src/Vhffs/Panel/Auth.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Auth.pm 2012-05-07 21:54:23 UTC (rev 2180)
+++ trunk/vhffs-api/src/Vhffs/Panel/Auth.pm 2012-05-08 00:03:19 UTC (rev 2181)
@@ -111,7 +111,7 @@
$user->update_lastloginpanel;
$user->commit;
- $panel->redirect('?do=home', [$sessioncookie, $themecookie, $langcookie]);
+ $panel->redirect('?do=groupindex', [$sessioncookie, $themecookie, $langcookie]);
}
}
Modified: trunk/vhffs-api/src/Vhffs/Panel/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Group.pm 2012-05-07 21:54:23 UTC (rev 2180)
+++ trunk/vhffs-api/src/Vhffs/Panel/Group.pm 2012-05-08 00:03:19 UTC (rev 2181)
@@ -264,11 +264,23 @@
$panel->set_title( gettext('My Projects') );
+ my $owned_projects = [];
+ my $contributed_projects = [];
+ foreach my $group ( @{$user->get_groups} ) {
+ if($group->get_owner_uid == $user->get_uid) {
+ push @{$owned_projects}, $group;
+ } else {
+ push @{$contributed_projects}, $group;
+ }
+ }
+
+ my $vars = {};
+ $vars->{owned_projects} = $owned_projects;
+ $vars->{contributed_projects} = $contributed_projects;
+ $vars->{url_help} = ( $panel->get_config->{'url_help'} or '' );
+
require Vhffs::Panel::User;
- $panel->render('group/index.tt', {
- owned_projects => Vhffs::Panel::User::get_groups($user, $Vhffs::Panel::User::RELATION_OWNER),
- contributed_projects => Vhffs::Panel::User::get_groups($user, $Vhffs::Panel::User::RELATION_CONTRIB)
- } );
+ $panel->render('group/index.tt', $vars);
}
sub create {
Deleted: trunk/vhffs-api/src/Vhffs/Panel/Home.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Home.pm 2012-05-07 21:54:23 UTC (rev 2180)
+++ trunk/vhffs-api/src/Vhffs/Panel/Home.pm 2012-05-08 00:03:19 UTC (rev 2181)
@@ -1,72 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-#3. Neither the name of vhffs nor the names of its contributors
-# may be used to endorse or promote products derived from this
-# software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-use strict;
-use utf8;
-
-package Vhffs::Panel::Home;
-
-use POSIX qw(locale_h);
-use locale;
-use Locale::gettext;
-use Encode;
-
-use Vhffs::Constants;
-use Vhffs::Functions;
-use Vhffs::User;
-
-
-sub home {
- my $panel = shift;
-
- my $vhffs = $panel->{'vhffs'};
- my $cgi = $panel->{'cgi'};
- my $session = $panel->{'session'};
- my $user = $panel->{'user'};
-
- my $vars = {};
-
- $panel->set_title( sprintf( gettext('Hello %s, welcome in VHFFS !'), $user->get_username() ) );
-
- # check groups quota
- my @overquota;
- foreach my $group ( @{$user->get_groups} ) {
- my $quota = $group->get_quota;
- my $curused = $group->get_quota_used;
- push @overquota, $group->get_groupname if $curused > $quota-$quota/10;
- }
- $vars->{overquota} = \@overquota;
-
- $vars->{url_help} = ( $panel->get_config->{'url_help'} or '' );
- $panel->render( 'misc/welcome.tt', $vars );
-}
-
-1;
Modified: trunk/vhffs-api/src/Vhffs/Panel/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/User.pm 2012-05-07 21:54:23 UTC (rev 2180)
+++ trunk/vhffs-api/src/Vhffs/Panel/User.pm 2012-05-08 00:03:19 UTC (rev 2181)
@@ -288,51 +288,6 @@
}
-=pod
-
-=head2 get_groups
-
- my $groups = Vhffs::Panel::User::get_groups($user);
- rint $groups->[0]->{project};
-
-Returns an array reference which contains all the groupname for
-a given user whose uid is C<$uid>.
-
-An optional second parameter can be used to restrict project
-list to owned or contributed project
-
-=cut
-
-sub get_groups {
- my $user = shift;
- my $relation = shift;
- my @params;
-
- my $groups = [];
- my $sql;
- push @params, $user->get_uid;
- if( defined $relation) {
- if( $relation == $RELATION_OWNER ) {
- $sql = 'SELECT g.groupname, o.state , o.object_id AS oid FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE o.owner_uid = ? AND g.groupname != ? ORDER BY g.groupname';
- push @params, $user->get_username;
- } else {
- $sql = 'SELECT g.groupname, o.state , o.object_id AS oid FROM vhffs_groups g INNER JOIN vhffs_user_group ug ON g.gid=ug.gid INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE ug.uid=? AND o.owner_uid != ug.uid ORDER BY g.groupname';
- }
- } else {
- $sql = 'SELECT g.groupname, o.state , o.object_id AS oid FROM vhffs_groups g INNER JOIN vhffs_user_group ug ON g.gid=ug.gid INNER JOIN vhffs_object o ON o.object_id = g.object_id WHERE ug.uid=? ORDER BY g.groupname';
- }
- my $sth = $user->get_db->prepare( $sql );
- return undef unless $sth->execute(@params);
- while(my $g = $sth->fetchrow_hashref) {
- $g->{active} = ($g->{state} == Vhffs::Constants::ACTIVATED);
- $g->{refused} = ($g->{state} == Vhffs::Constants::VALIDATION_REFUSED);
- $g->{state} = Vhffs::Functions::status_string_from_status_id($g->{state});
- push @$groups, $g;
- }
- return $groups;
-}
-
-
sub prefs {
my $panel = shift;
Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm 2012-05-07 21:54:23 UTC (rev 2180)
+++ trunk/vhffs-api/src/Vhffs/User.pm 2012-05-08 00:03:19 UTC (rev 2181)
@@ -1072,18 +1072,32 @@
my @groups = $user->get_groups;
-Returns an array of all of the user groups.
+Returns an array of all of the user groups, except the user primary group.
=cut
sub get_groups {
my $self = shift;
- my $groups = [];
- my $query = 'SELECT g.groupname FROM vhffs_groups g INNER JOIN vhffs_user_group ug ON g.gid=ug.gid WHERE ug.uid=? ORDER BY g.groupname';
+ my $groupnames = {};
+
+ my $query = 'SELECT g.groupname FROM vhffs_groups g INNER JOIN vhffs_user_group ug ON g.gid=ug.gid WHERE ug.uid=?';
my $request = $self->get_db->prepare( $query );
- return undef unless $request->execute($self->get_uid);
+ return unless $request->execute($self->get_uid);
while( my ($groupname) = $request->fetchrow_array ) {
- my $group = Vhffs::Group::get_by_groupname( $self->get_vhffs, $groupname );
+ $groupnames->{$groupname} = 1;
+ }
+
+ # owned groups
+ $query = 'SELECT g.groupname FROM vhffs_groups g INNER JOIN vhffs_object o ON o.object_id=g.object_id WHERE o.owner_uid=? AND g.gid!=?';
+ $request = $self->get_db->prepare( $query );
+ return unless $request->execute($self->get_uid, $self->get_gid);
+ while( my ($groupname) = $request->fetchrow_array ) {
+ $groupnames->{$groupname} = 1;
+ }
+
+ my $groups = [];
+ foreach( sort keys %{$groupnames} ) {
+ my $group = Vhffs::Group::get_by_groupname( $self->get_vhffs, $_ );
push( @$groups, $group ) if defined $group;
}
return $groups;
Modified: trunk/vhffs-panel/index.pl
===================================================================
--- trunk/vhffs-panel/index.pl 2012-05-07 21:54:23 UTC (rev 2180)
+++ trunk/vhffs-panel/index.pl 2012-05-08 00:03:19 UTC (rev 2181)
@@ -81,10 +81,7 @@
# -- session required
my $session = ( $panel->get_session or next );
- if( $do eq 'home' ) {
- require Vhffs::Panel::Home;
- Vhffs::Panel::Home::home( $panel );
- } elsif( $do eq 'contact' ) {
+ if( $do eq 'contact' ) {
require Vhffs::Panel::Contact;
Vhffs::Panel::Contact::contact( $panel );
} elsif( $do eq 'acl' ) {
Modified: trunk/vhffs-panel/templates/Makefile.am
===================================================================
--- trunk/vhffs-panel/templates/Makefile.am 2012-05-07 21:54:23 UTC (rev 2180)
+++ trunk/vhffs-panel/templates/Makefile.am 2012-05-08 00:03:19 UTC (rev 2181)
@@ -61,7 +61,6 @@
misc/languages.tt \
misc/message.tt \
misc/service-index.tt \
- misc/welcome.tt \
mercurial/create.tt \
mysql/create.tt \
object/delete.tt \
Modified: trunk/vhffs-panel/templates/group/index.tt
===================================================================
--- trunk/vhffs-panel/templates/group/index.tt 2012-05-07 21:54:23 UTC (rev 2180)
+++ trunk/vhffs-panel/templates/group/index.tt 2012-05-08 00:03:19 UTC (rev 2181)
@@ -1,3 +1,4 @@
+<p>[% 'If you are new to VHFFS, you should start to read briefly the whole <a href="%s">help</a> available.' | i18n | pretty_print(url_help) %]</p>
[% IF owned_projects.size() %]
<div id="ownedProjects">
<h2>[% 'Your projects' | i18n | html %]</h2>
@@ -3,12 +4,18 @@
<ul>
[% FOR p IN owned_projects %]
-[% IF p.active %]
- <li><a href="?do=groupview;group=[% p.groupname | html %]">[% p.groupname | html %]</a></li>
+[% IF p.get_status == constants.object_statuses.ACTIVATED %]
+ <li><a href="?do=groupview;group=[% p.get_groupname | html %]">[% p.get_groupname | html %]</a>
+ <p>[% 'Quota (used/total): %d/%dMB' | i18n | pretty_print(p.get_quota_used, p.get_quota) | html %] —
+ <span class="quota">
+ <span class="quota-used" style="width:[% (p.get_quota_used / p.get_quota * 100) | format('%d') %]%" title="[% (p.get_quota_used / p.get_quota * 100) | format('%.2f') %]%"></span>
+ </span></p>
+ </li>
[% ELSE %]
- <li>[% p.groupname | html %] — [% p.state | html %]
- [% IF p.refused %]
- - <a href="?do=objectresubmit;oid=[% p.oid %]">[% 'Propose a new description' | i18n | html %]</a>
- - <a href="?do=objectcancel;oid=[% p.oid %]">[% 'Delete' | i18n | html %]</a>
+ <li>[% p.get_groupname | html %] — [% p.get_status | stringify_status | html %]
+ [% IF p.get_status == constants.object_statuses.VALIDATION_REFUSED %]
+ - <a href="?do=objectresubmit;oid=[% p.get_oid %]">[% 'Propose a new description' | i18n | html %]</a>
+ - <a href="?do=objectcancel;oid=[% p.get_oid %]">[% 'Delete' | i18n | html %]</a>
[% END %]
+ <p/>
</li>
[% END %]
@@ -17,23 +24,23 @@
</ul>
</div>
[% END %]
-[% IF contributed_projects %]
+[% IF contributed_projects.size() %]
<div id="contribProjects">
<h2>[% 'Projects you contribute to' | i18n | html %]</h2>
<ul>
[% FOR p IN contributed_projects %]
-[% IF p.active %]
- <li><a href="?do=groupview;group=[% p.groupname | html %]">[% p.groupname | html %]</a></li>
+[% IF p.get_status == constants.object_statuses.ACTIVATED %]
+ <li><a href="?do=groupview;group=[% p.get_groupname | html %]">[% p.get_groupname | html %]</a>
+ <p>[% 'Quota (used/total): %d/%dMB' | i18n | pretty_print(p.get_quota_used, p.get_quota) | html %] —
+ <span class="quota">
+ <span class="quota-used" style="width:[% (p.get_quota_used / p.get_quota * 100) | format('%d') %]%" title="[% (p.get_quota_used / p.get_quota * 100) | format('%.2f') %]%"></span>
+ </span></p>
+ </li>
[% ELSE %]
- <li>[% p.groupname | html %] — [% p.state | html %]
- [% IF p.refused %]
- - <a href="?do=objectresubmit;oid=[% p.oid %]">[% 'Propose a new description' | i18n | html %]</a>
- - <a href="?do=objectcancel;oid=[% p.oid %]">[% 'Delete' | i18n | html %]</a>
- [% END %]
- </li>
+ <li>[% p.get_groupname | html %] — [% p.get_status | stringify_status | html %]</li>
[% END %]
[% END %]
</ul>
</div>
[% END %]
-<a href="?do=groupcreate">[% 'Create new project' | i18n | html %]</a>
+<p><a href="?do=groupcreate">[% 'Create new project' | i18n | html %]</a></p>
Modified: trunk/vhffs-panel/templates/misc/header.tt
===================================================================
--- trunk/vhffs-panel/templates/misc/header.tt 2012-05-07 21:54:23 UTC (rev 2180)
+++ trunk/vhffs-panel/templates/misc/header.tt 2012-05-08 00:03:19 UTC (rev 2181)
@@ -12,9 +12,8 @@
<!-- Navigation Level 1 -->
<div class="nav1">
- <a href="?do=home">[% 'Home' | i18n | html %]</a>
- <a href="?do=userprefs">[% 'Preferences' | i18n | html %]</a>
<a href="?do=groupindex">[% 'Projects' | i18n | html %]</a>
+ <a href="?do=userprefs">[% 'Preferences' | i18n | html %]</a>
[% IF current_user.is_admin() OR current_user.is_moderator() %]
<a href="?do=admin">[% 'Administration' | i18n | html %]</a>
[% END %]
Deleted: trunk/vhffs-panel/templates/misc/welcome.tt
===================================================================
--- trunk/vhffs-panel/templates/misc/welcome.tt 2012-05-07 21:54:23 UTC (rev 2180)
+++ trunk/vhffs-panel/templates/misc/welcome.tt 2012-05-08 00:03:19 UTC (rev 2181)
@@ -1,11 +0,0 @@
-[% 'If you are new to VHFFS, you should start to read briefly the whole <a href="%s">help</a> available.' | i18n | pretty_print(url_help) %]
-[% IF over_quota.size() %]
-<div id="overQuota">
-<h2>[% 'The following projects have reached or are going to reach the disk quota limit, please take a look !' | i18n | html %]</h2>
-<ul>
-[% FOR g IN overquota %]
- <li><a href="?do=groupview;group=[% g %]">[% g %]</a></li>
-[% END %]
-</ul>
-</div>
-[% END %]