Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temp/0.23 stable #45

Draft
wants to merge 42 commits into
base: release/0.23-stable
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3dc0783
Archive Debates (#6940)
verarojman Dec 10, 2020
16507f5
Export debate comments (#6962)
verarojman Dec 14, 2020
2650bb8
Improve layout for standalone T&C page (#6944)
verarojman Dec 1, 2020
7a700d7
Add time type for settings manifest attributes (#6948)
verarojman Dec 17, 2020
416d9dd
Start and end dates for survey (#6948)
verarojman Dec 17, 2020
ff2a447
Start and end dates for survey (#7016)
verarojman Dec 17, 2020
5a9b02a
Merge branch 'feature/cherry-picks' of github.com:platoniq/decidim in…
verarojman Dec 17, 2020
bf285d5
Merge pull request #47 from Platoniq/feature/cherry-picks
Dec 17, 2020
1ce358f
Debates with no start and end time (#6959) (#48)
Dec 17, 2020
d39daf3
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Dec 18, 2020
d789225
Notify users when their comments are voted (#7055) (#53)
Dec 22, 2020
b12306b
Fix bug in seeds (#55)
Dec 23, 2020
c5be4e3
Fix compatibility with Faker 1.9 in debates seeds (#56)
Dec 23, 2020
2bfe844
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Jan 8, 2021
3530d59
Backport/comment permissions (#63)
microstudi Jan 11, 2021
6629399
Add jitsi embeded + others (#6572) (#66)
microstudi Jan 12, 2021
7cb76be
Add videoconference.js to meetings js manifest (#67)
Jan 13, 2021
aedbc36
Filter assemblies by type (decidim/decidim#7153) (#71)
Jan 14, 2021
7ee4ef0
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Jan 15, 2021
bc74cbf
Remove non-alphanumeric characters when generating room name (#72) 18…
Jan 15, 2021
e10b69e
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Jan 29, 2021
fed7db9
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Feb 5, 2021
8a55a32
Create file uploads question type (#7192)
microstudi Feb 5, 2021
5fb7cbb
lint
microstudi Feb 5, 2021
4812827
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Feb 10, 2021
42a73d1
rebuild bundle js
microstudi Feb 10, 2021
11b40b4
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Feb 15, 2021
025a306
lint
microstudi Feb 15, 2021
dffe0a2
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Feb 17, 2021
f65b943
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Feb 22, 2021
a4c3a31
Fix datepicker tests to not match upcoming month's days (#7256)
mrcasals Feb 1, 2021
52fc5f0
Fix debates with multiple days (#79)
Feb 23, 2021
8e5e589
Max characters for questionnaire answers (#7314) (#77)
Feb 23, 2021
f752be3
Update jitsi meetings (prevent error with online_meeting_url) (#78)
Feb 23, 2021
a1dec57
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Feb 24, 2021
3f75070
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Mar 2, 2021
9fd8c83
Fix the proposal body validation error messages (#7156)
ahukkanen Jan 15, 2021
1679ef5
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Mar 3, 2021
47870be
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Mar 4, 2021
52978a8
Add css selectors to emails to improve design customization (#7493) (…
Mar 5, 2021
677b952
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Mar 16, 2021
87af39f
Merge branch 'release/0.23-stable' into temp/0.23-stable
microstudi Apr 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 189 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions config/i18n-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ data:
# `i18n-tasks normalize -p` will force move the keys according to these rules
write:
<% Dir.glob("decidim-*").each do |path| -%>
<%= "- ['#{path.sub('-', '.')}.*', '#{path}/config/locales/%{locale}.yml']" %>
<%= "- ['#{path.sub('-', '.')}.*', '#{path}/config/locales/%{locale}.yml']" %>
<% end -%>
- 'decidim-core/config/locales/%{locale}.yml'
- 'decidim-core/config/locales/%{locale}.yml'

## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
# router: convervative_router
Expand All @@ -45,20 +45,20 @@ search:
## Paths or `File.find` patterns to search in:
paths:
<% Dir.glob("decidim-*").each do |path| -%>
<%= "- #{path}/app\n" %>
<%= "- #{path}/lib\n" %>
<%= "- #{path}/app\n" %>
<%= "- #{path}/lib\n" %>
<% end -%>

# Root directories for relative keys resolution.
relative_roots:
<% Dir.glob("decidim-*").each do |path| -%>
<%= "- #{path}/app/controllers\n" %>
<%= "- #{path}/app/helpers\n" %>
<%= "- #{path}/app/mailers\n" %>
<%= "- #{path}/app/presenters\n" %>
<%= "- #{path}/app/services\n" %>
<%= "- #{path}/app/views\n" %>
<%= "- #{path}/app/cells\n" %>
<%= "- #{path}/app/controllers\n" %>
<%= "- #{path}/app/helpers\n" %>
<%= "- #{path}/app/mailers\n" %>
<%= "- #{path}/app/presenters\n" %>
<%= "- #{path}/app/services\n" %>
<%= "- #{path}/app/views\n" %>
<%= "- #{path}/app/cells\n" %>
<% end -%>

## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
Expand Down
3 changes: 2 additions & 1 deletion decidim-admin/app/helpers/decidim/admin/settings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ module SettingsHelper
string: :text_field,
text: :text_area,
scope: :scope_field,
enum: :collection_radio_buttons
enum: :collection_radio_buttons,
time: :datetime_field
}.freeze

# Public: Renders a form field that matches a settings attribute's
Expand Down
9 changes: 9 additions & 0 deletions decidim-admin/spec/helpers/settings_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ def render_input
render_input
end
end

describe "times" do
let(:type) { :time }

it "is supported" do
expect(form).to receive(:datetime_field).with(:test, options)
render_input
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ def base_query
def extra_filters
[:parent_id_eq]
end

def filters
[:private_space_eq, :published_at_null, :decidim_assemblies_type_id_eq]
end

def filters_with_values
{
private_space_eq: [true, false],
published_at_null: [true, false],
decidim_assemblies_type_id_eq: AssembliesType.where(organization: current_organization).pluck(:id)
}
end

def dynamically_translated_filters
[:decidim_assemblies_type_id_eq]
end

def translated_decidim_assemblies_type_id_eq(id)
translated_attribute(Decidim::AssembliesType.find_by(id: id).title[I18n.locale.to_s])
end
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions decidim-assemblies/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ en:
update:
error: There was a problem updating an admin for this assembly.
success: Admin updated successfully for this assembly.
filters:
decidim_assemblies_type_id_eq:
label: Assembly type
menu:
assemblies: Assemblies
assemblies_settings: Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,37 @@
describe "listing parent assemblies" do
it_behaves_like "filtering collection by published/unpublished"
it_behaves_like "filtering collection by private/public"

context "when filtering by assemblies type" do
include_context "with filterable context"

let!(:assemblies_type_1) { create(:assemblies_type) }
let!(:assemblies_type_2) { create(:assemblies_type) }

Decidim::AssembliesType.all.each do |assemblies_type|
i18n_assemblies_type = assemblies_type.name[I18n.locale.to_s]

context "filtering collection by assemblies_type: #{i18n_assemblies_type}" do
let!(:assembly_1) { create(:assembly, organization: organization, assemblies_type: assemblies_type_1) }
let!(:assembly_2) { create(:assembly, organization: organization, assemblies_type: assemblies_type_2) }

it_behaves_like "a filtered collection", options: "Assembly type", filter: i18n_assemblies_type do
let(:in_filter) { translated(assembly_with_type(type).title) }
let(:not_in_filter) { translated(assembly_without_type(type).title) }
end
end
end

it_behaves_like "paginating a collection"

def assembly_with_type(type)
Decidim::Assembly.find_by(decidim_assemblies_type_id: type)
end

def assembly_without_type(type)
Decidim::Assembly.where.not(decidim_assemblies_type_id: type).sample
end
end
end
end

Expand Down
1 change: 1 addition & 0 deletions decidim-budgets/lib/decidim/budgets/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
resource.card = "decidim/budgets/project"
resource.actions = %(vote)
resource.searchable = true
resource.parent_resource = "budget" # method to access parent resource
end

component.register_stat :budgets_count, primary: true, priority: Decidim::StatsRegistry::LOW_PRIORITY do |components|
Expand Down

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions decidim-comments/app/commands/decidim/comments/vote_comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,39 @@ def call
if vote
vote.destroy!
else
@comment.up_votes.create!(author: @author)
@vote = @comment.up_votes.create!(author: @author)
end
elsif @weight == -1
vote = @comment.down_votes.find_by(author: @author)
if vote
vote.destroy!
else
@comment.down_votes.create!(author: @author)
@vote = @comment.down_votes.create!(author: @author)
end
else
return broadcast(:invalid)
end

notify_comment_author if @vote
broadcast(:ok, @comment)
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique
broadcast(:invalid)
end

def notify_comment_author
Decidim::EventsManager.publish(
event: "decidim.events.comments.comment_voted",
event_class: Decidim::Comments::CommentVotedEvent,
resource: @comment.commentable,
affected_users: [@author],
followers: [@comment.author],
extra: {
comment_id: @comment.id,
author_id: @author.id,
weight: @weight
}
)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Decidim
module Comments
class CommentVotedEvent < Decidim::Events::SimpleEvent
include Decidim::Comments::CommentEvent

delegate :author, to: :comment_vote

private

def comment_vote
@comment_vote ||= Decidim::Comments::CommentVote.find_by(decidim_comment_id: extra[:comment_id], decidim_author_id: extra[:author_id])
end

def resource_url_params
{ anchor: "comment_#{comment.id}" }
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface AddCommentFormProps {
submitButtonClassName?: string;
autoFocus?: boolean;
arguable?: boolean;
userAllowedToComment?: boolean;
userAllowedToComment?: number;
addComment?: (data: { body: string, alignment: number, userGroupId?: string }, context: any) => void;
onCommentAdded?: () => void;
orderBy: string;
Expand Down Expand Up @@ -404,7 +404,7 @@ const AddCommentFormWithMutation = graphql<addCommentMutation, AddCommentFormPro
comments: [],
hasComments: false,
acceptsNewComments: false,
userAllowedToComment: false,
userAllowedToComment: 0,
upVotes: 0,
upVoted: false,
downVotes: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ describe("<Comment />", () => {

describe("when user is not allowed to comment", () => {
beforeEach(() => {
comment.userAllowedToComment = false;
comment.userAllowedToComment = 0;
});

it("should not render reply button", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("<Comments commentsMaxLength={commentsMaxLength} />", () => {
},
commentable: {
acceptsNewComments: true,
userAllowedToComment: true,
userAllowedToComment: 1,
commentsHaveAlignment: true,
commentsHaveVotes: true,
totalCommentsCount: 15,
Expand Down Expand Up @@ -106,7 +106,7 @@ describe("<Comments commentsMaxLength={commentsMaxLength} />", () => {
describe("when the commentable cannot accept new comments", () => {
beforeEach(() => {
commentable.acceptsNewComments = false;
commentable.userAllowedToComment = false;
commentable.userAllowedToComment = 0;
});

it("doesn't render an AddCommentForm component", () => {
Expand All @@ -122,7 +122,7 @@ describe("<Comments commentsMaxLength={commentsMaxLength} />", () => {

describe("when the commentable can accept new comments but user is not allowed to comment", () => {
beforeEach(() => {
commentable.userAllowedToComment = false;
commentable.userAllowedToComment = 0;
});

it("doesn't render an AddCommentForm component", () => {
Expand Down
33 changes: 23 additions & 10 deletions decidim-comments/app/frontend/comments/comments.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface CommentsProps extends GetCommentsQuery {
loading?: boolean;
orderBy: string;
singleCommentId?: string;
authorizationLink?: string;
reorderComments: (orderBy: string) => void;
commentsMaxLength: number;
}
Expand Down Expand Up @@ -142,7 +143,7 @@ export class Comments extends React.Component<CommentsProps> {
private _renderBlockedCommentsWarning() {
const { commentable: { acceptsNewComments, userAllowedToComment } } = this.props;

if (!acceptsNewComments && !userAllowedToComment) {
if (!acceptsNewComments && userAllowedToComment !== 1) {
return (
<div className="callout warning">
<p>{I18n.t("components.comments.blocked_comments_warning")}</p>
Expand All @@ -160,15 +161,25 @@ export class Comments extends React.Component<CommentsProps> {
* @returns {Void|DOMElement} - A warning message or nothing.
*/
private _renderBlockedCommentsForUserWarning() {
const { commentable: { acceptsNewComments, userAllowedToComment } } = this.props;
const { authorizationLink, commentable } = this.props;
const { acceptsNewComments, userAllowedToComment } = commentable;
const link = { __html: authorizationLink ? authorizationLink : I18n.t("components.comments.blocked_comments_for_unauthorized_user_warning") };

if (acceptsNewComments) {
if (!userAllowedToComment) {
return (
<div className="callout warning">
<p>{I18n.t("components.comments.blocked_comments_for_user_warning")}</p>
</div>
);
if (userAllowedToComment !== 1) {
if (userAllowedToComment === -1) {
return (
<div className="callout warning">
<div dangerouslySetInnerHTML={link} />
</div>
);
} else {
return (
<div className="callout warning">
<p>{I18n.t("components.comments.blocked_comments_for_user_warning")}</p>
</div>
);
}
}
}

Expand Down Expand Up @@ -210,7 +221,7 @@ export class Comments extends React.Component<CommentsProps> {
return null;
}

if (acceptsNewComments && userAllowedToComment) {
if (acceptsNewComments && userAllowedToComment === 1) {
return (
<AddCommentForm
session={session}
Expand Down Expand Up @@ -265,14 +276,15 @@ export interface CommentsApplicationProps extends GetCommentsQueryVariables {
locale: string;
toggleTranslations: boolean;
commentsMaxLength: number;
authorizationLink: string;
}

/**
* Wrap the CommentsWithData component within an Application component to
* connect it with Apollo client and store.
* @returns {ReactComponent} - A component wrapped within an Application component
*/
const CommentsApplication: React.SFC<CommentsApplicationProps> = ({ locale, toggleTranslations, commentableId, commentableType, singleCommentId, commentsMaxLength }) => (
const CommentsApplication: React.SFC<CommentsApplicationProps> = ({ locale, toggleTranslations, commentableId, commentableType, singleCommentId, commentsMaxLength, authorizationLink }) => (
<Application locale={locale}>
<CommentsWithData
commentsMaxLength={commentsMaxLength}
Expand All @@ -282,6 +294,7 @@ const CommentsApplication: React.SFC<CommentsApplicationProps> = ({ locale, togg
toggleTranslations={toggleTranslations}
orderBy="older"
singleCommentId={singleCommentId}
authorizationLink={authorizationLink}
/>
</Application>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const generateCommentsData = (num = 1) => {
hasComments: false,
comments: [],
acceptsNewComments: true,
userAllowedToComment: true,
userAllowedToComment: 1,
alignment: 0,
upVotes: random.number(),
upVoted: false,
Expand Down
Loading