Interact with new intranet group API
This commit is contained in:
parent
27f7b7c9ce
commit
1f61b7a144
3 changed files with 135 additions and 0 deletions
|
|
@ -46,6 +46,7 @@ sub parse($$)
|
||||||
$sax_handler = ProjectHandler->new($parsed);
|
$sax_handler = ProjectHandler->new($parsed);
|
||||||
}
|
}
|
||||||
$sax_handler = ProjectMemberHandler->new($parsed) if ($mod eq "ProjectMemberHandler");
|
$sax_handler = ProjectMemberHandler->new($parsed) if ($mod eq "ProjectMemberHandler");
|
||||||
|
$sax_handler = ProjectGroupHandler->new($parsed) if ($mod eq "ProjectGroupHandler");
|
||||||
|
|
||||||
my $parser = XML::SAX::ParserFactory->parser( Handler => $sax_handler );
|
my $parser = XML::SAX::ParserFactory->parser( Handler => $sax_handler );
|
||||||
|
|
||||||
|
|
@ -234,4 +235,81 @@ sub end_element
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
package ProjectGroupHandler;
|
||||||
|
|
||||||
|
use v5.10.1;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub new ($$)
|
||||||
|
{
|
||||||
|
my $class = shift;
|
||||||
|
my $self = {
|
||||||
|
parsed => shift,
|
||||||
|
inStd => 0,
|
||||||
|
inResult => 0,
|
||||||
|
lastGroup => {},
|
||||||
|
values => ""
|
||||||
|
};
|
||||||
|
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub start_element
|
||||||
|
{
|
||||||
|
my ($self, $element) = @_;
|
||||||
|
|
||||||
|
if ($element->{Name} eq "result") {
|
||||||
|
$self->{parsed}{result} = $self->{values};
|
||||||
|
$self->{inResult} = 0;
|
||||||
|
$self->{values} = "";
|
||||||
|
}
|
||||||
|
elsif ($element->{Name} eq "student")
|
||||||
|
{
|
||||||
|
$self->{inStd} = 1;
|
||||||
|
push @{ $self->{lastGroup}{stds} }, {
|
||||||
|
id => $element->{Attributes}{"{}id"}{Value},
|
||||||
|
chief => $element->{Attributes}{"{}chief"}{Value},
|
||||||
|
login => "",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
elsif ($element->{Name} eq "group")
|
||||||
|
{
|
||||||
|
$self->{lastGroup}{id} = $element->{Attributes}{"{}id"}{Value};
|
||||||
|
$self->{lastGroup}{stds} = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub characters
|
||||||
|
{
|
||||||
|
my ($self, $characters) = @_;
|
||||||
|
|
||||||
|
if ($self->{inStd}) {
|
||||||
|
$self->{values} .= $characters->{Data};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub end_element
|
||||||
|
{
|
||||||
|
my ($self, $element) = @_;
|
||||||
|
|
||||||
|
if ($element->{Name} eq "group")
|
||||||
|
{
|
||||||
|
push @{ $self->{parsed}{groups} }, $self->{lastGroup};
|
||||||
|
$self->{lastGroup} = {};
|
||||||
|
|
||||||
|
$self->{inStd} = 0;
|
||||||
|
$self->{values} = "";
|
||||||
|
}
|
||||||
|
elsif ($element->{Name} eq "student")
|
||||||
|
{
|
||||||
|
my $size = @{ $self->{lastGroup}{stds} };
|
||||||
|
(@{ $self->{lastGroup}{stds} })[$size - 1]{login} = $self->{values};
|
||||||
|
$self->{values} = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,28 @@ sub get_users($;$)
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub get_groups($;$)
|
||||||
|
{
|
||||||
|
my $project_name = shift;
|
||||||
|
my $year = shift;
|
||||||
|
|
||||||
|
my $url;
|
||||||
|
if ($year) {
|
||||||
|
$url = "projects/groups/groups/$project_name/$year.xml";
|
||||||
|
} else {
|
||||||
|
$url = "projects/groups/groups/$project_name.xml";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $res = API::Base::get('ProjectGroupHandler', $url);
|
||||||
|
|
||||||
|
#TODO: uncomment-me
|
||||||
|
#if ($res->{result} ne '0') {
|
||||||
|
# croak "Erreur durant la récupération : " . $res->{message};
|
||||||
|
#}
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
sub add_grades($;$)
|
sub add_grades($;$)
|
||||||
{
|
{
|
||||||
my %data = (
|
my %data = (
|
||||||
|
|
|
||||||
35
commands/project/gen_git_str.pl
Normal file
35
commands/project/gen_git_str.pl
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use v5.10;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
use ACU::API::Projects;
|
||||||
|
|
||||||
|
my $projid = $ARGV[0];
|
||||||
|
my $year = $ARGV[1] // LDAP::get_year;
|
||||||
|
|
||||||
|
my $res = API::Projects::get_groups($projid, $year);
|
||||||
|
my $tag = "rendu-1";
|
||||||
|
|
||||||
|
map {
|
||||||
|
my $chief;
|
||||||
|
|
||||||
|
# First, found the chief
|
||||||
|
for my $member (@{ $_->{stds} })
|
||||||
|
{
|
||||||
|
if ($member->{chief} eq "true" or $member->{chief} eq "1" or $member->{chief} eq "chief")
|
||||||
|
{
|
||||||
|
$chief = $member;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
say "repo $year/$projid/$chief->{login}";
|
||||||
|
print ' RW+ = @admins';
|
||||||
|
for my $member (@{ $_->{stds} }) {
|
||||||
|
print ' '.$member->{login};
|
||||||
|
}
|
||||||
|
say "\n R = \@chefs \@resp-$year-$projid";
|
||||||
|
} @{ $res->{groups} };
|
||||||
Reference in a new issue