Skip to content
This repository was archived by the owner on Nov 19, 2021. It is now read-only.

Commit bf5bf26

Browse files
committed
Merge branch 'dev'
2 parents 9f45264 + e1a9e39 commit bf5bf26

34 files changed

+772
-356
lines changed

cpanfile

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ requires 'Plack::Middleware::Debug', '0.16';
8888
requires 'Prosody', '0.007';
8989
requires 'String::ProgressBar', '0.03';
9090
requires 'Test::WWW::Mechanize::Catalyst', '0.58';
91+
requires 'Test::EOL', '1.5';
9192
requires 'Text::VimColor', '0.20';
9293
requires 'Text::Fuzzy', '0.14';
9394
requires 'Text::CSV', '1.32';

lib/DDGC/Web/Controller/Forum/My.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ sub thread : Chained('base') CaptureArgs(1) {
8080
$c->response->redirect($c->chained_uri('Forum','general',{ thread_notfound => 1 }));
8181
return $c->detach;
8282
}
83-
unless ($c->user->admin || $c->stash->{thread}->users_id == $c->user->id) {
83+
unless ($c->user->is('forum_manager') || $c->stash->{thread}->users_id == $c->user->id) {
8484
$c->response->redirect($c->chained_uri('Forum','general',{ thread_notallowed => 1 }));
8585
return $c->detach;
8686
}

lib/DDGC/Web/Controller/InstantAnswer.pm

+52-25
Original file line numberDiff line numberDiff line change
@@ -123,28 +123,31 @@ sub ia_base :Chained('base') :PathPart('view') :CaptureArgs(1) { # /ia/view/cal
123123

124124
my $permissions;
125125
my $is_admin;
126-
my $edit_class = "hide";
126+
my $can_edit;
127+
my $can_commit;
127128
my $commit_class = "hide";
128129

129130
if ($c->user) {
130131
$permissions = $c->stash->{ia}->users->find($c->user->id);
131132
$is_admin = $c->user->admin;
132-
}
133133

134-
if ($permissions || $is_admin) {
135-
$edit_class = "";
134+
if ($permissions || $is_admin) {
135+
$can_edit = 1;
136136

137-
if ($is_admin) {
138-
my $edits = get_edits($c->d, $c->stash->{ia}->name);
137+
if ($is_admin) {
138+
my $edits = get_edits($c->d, $c->stash->{ia}->name);
139+
$can_commit = 1;
139140

140-
if (ref $edits eq 'ARRAY') {
141-
$commit_class = "";
141+
if (length $edits && ref $edits eq 'HASH') {
142+
$commit_class = '';
143+
}
142144
}
143145
}
144146
}
145147

146148
$c->stash->{title} = $c->stash->{ia}->name;
147-
$c->stash->{edit_class} = $edit_class;
149+
$c->stash->{can_edit} = $can_edit;
150+
$c->stash->{can_commit} = $can_commit;
148151
$c->stash->{commit_class} = $commit_class;
149152

150153
my @topics = $c->d->rs('Topic')->search(
@@ -165,9 +168,12 @@ sub ia_json :Chained('ia_base') :PathPart('json') :Args(0) {
165168

166169
my $ia = $c->stash->{ia};
167170
my @topics = map { $_->name} $ia->topics;
168-
169-
my @issues = $c->d->rs('InstantAnswer::Issues')->find({instant_answer_id => $ia->id});
170-
my @ia_issues;
171+
my $edited;
172+
my @issues = $c->d->rs('InstantAnswer::Issues')->search({instant_answer_id => $ia->id});
173+
my @ia_issues;
174+
my %ia_data;
175+
my $permissions;
176+
my $is_admin;
171177

172178
for my $issue (@issues) {
173179
if ($issue) {
@@ -180,7 +186,9 @@ sub ia_json :Chained('ia_base') :PathPart('json') :Args(0) {
180186
}
181187
}
182188

183-
$c->stash->{x} = {
189+
my $other_queries = $ia->other_queries? decode_json($ia->other_queries) : undef;
190+
191+
$ia_data{live} = {
184192
id => $ia->id,
185193
name => $ia->name,
186194
description => $ia->description,
@@ -190,14 +198,33 @@ sub ia_json :Chained('ia_base') :PathPart('json') :Args(0) {
190198
dev_milestone => $ia->dev_milestone,
191199
perl_module => $ia->perl_module,
192200
example_query => $ia->example_query,
193-
other_queries => $ia->other_queries? decode_json($ia->other_queries) : undef,
201+
other_queries => $other_queries,
194202
code => $ia->code? decode_json($ia->code) : undef,
195203
topic => \@topics,
196204
attribution => $ia->attribution? decode_json($ia->attribution) : undef,
197205
issues => \@ia_issues,
198206
template => $ia->template,
199207
};
200208

209+
if ($c->user) {
210+
$permissions = $c->stash->{ia}->users->find($c->user->id);
211+
$is_admin = $c->user->admin;
212+
213+
if ($is_admin || $permissions) {
214+
$edited = current_ia($c->d, $ia);
215+
$ia_data{edited} = {
216+
name => $edited->{name},
217+
description => $edited->{description},
218+
status => $edited->{status},
219+
example_query => $edited->{example_query},
220+
other_queries => $edited->{other_queries}->{value},
221+
topic => $edited->{topic},
222+
};
223+
}
224+
}
225+
226+
$c->stash->{x} = \%ia_data;
227+
201228
$c->stash->{not_last_url} = 1;
202229
$c->forward($c->view('JSON'));
203230
}
@@ -307,16 +334,8 @@ sub commit_save :Chained('commit_base') :PathPart('save') :Args(0) {
307334
}
308335
}
309336
}
310-
311-
my $edits = get_edits($c->d, $ia->name);
312337

313-
if (ref $edits eq 'ARRAY') {
314-
foreach my $edit (@{$edits}) {
315-
foreach my $field(keys %{$edit}){
316-
remove_edit($ia, $field);
317-
}
318-
}
319-
}
338+
remove_edits($ia);
320339
}
321340
}
322341

@@ -411,7 +430,7 @@ sub current_ia {
411430
sub add_edit {
412431
my ($ia, $field, $value ) = @_;
413432

414-
my $orig_data = $ia->get_column($field);
433+
my $orig_data = $ia->get_column($field) || '';
415434
my $current_updates = $ia->get_column('updates') || ();
416435

417436
if($value ne $orig_data){
@@ -448,10 +467,18 @@ sub remove_edit {
448467
my $column_updates = $ia->get_column('updates');
449468
my $edits = $column_updates? decode_json($column_updates) : undef;
450469
$edits->{$field} = undef;
451-
470+
452471
$ia->update({updates => $edits});
453472
}
454473

474+
# given a result set, remove
475+
# all the entries from the updates column
476+
sub remove_edits {
477+
my($ia) = @_;
478+
479+
$ia->update({updates => ''});
480+
}
481+
455482
# given the IA name return the data in the updates
456483
# column as an array of hashes
457484
sub get_edits {

lib/DDGC/Web/Controller/Translate.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ sub token :Chained('logged_in') :Args(1) {
7272

7373
for (keys %{$c->req->params}) {
7474
if ($_ =~ m/token_notes_(\d+)_edit$/) {
75-
my $token = $c->d->resultset('Token')->find({ id => $token_id });
75+
my $token = $c->d->resultset('Token')->find($_);
7676
$token->notes($c->req->params->{$_});
7777
$token->update;
7878
}
@@ -115,7 +115,7 @@ sub token :Chained('logged_in') :Args(1) {
115115

116116
sub tokenlanguage :Chained('logged_in') :Args(1) {
117117
my ( $self, $c, $token_language_id ) = @_;
118-
$self->save_translate_params($c) if ($c->req->params->{save_translation});
118+
$self->save_translate_params($c) if ($c->req->params->{save_translations});
119119
if ($c->wiz_inside && $c->req->params->{wizard_skip}) {
120120
push @{$c->wiz->unwanted_ids}, $token_language_id;
121121
$c->wiz_step;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ddg_community_platform",
3-
"version": "0.53.0",
3+
"version": "0.54.0",
44
"engines": {
55
"node": ">=0.10.0"
66
},

root/static/css/ddgc0.53.0.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

root/static/css/ia0.53.0.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)