Skip to content

Commit

Permalink
Merge branch 'main' into public-access
Browse files Browse the repository at this point in the history
  • Loading branch information
ostcar authored Oct 21, 2024
2 parents c269ce5 + 9017e5e commit d2da57d
Show file tree
Hide file tree
Showing 11 changed files with 654 additions and 1,102 deletions.
1 change: 0 additions & 1 deletion internal/projector/slide/meeting.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type dbMeeting struct {
MotionsEnableReasonOnProjector bool `json:"motions_enable_reason_on_projector"`
MotionsShowReferringMotions bool `json:"motions_show_referring_motions"`
MotionsEnableRecommendationOnProjector bool `json:"motions_enable_recommendation_on_projector"`
MotionsStatuteRecommendationsBy string `json:"motions_statute_recommendations_by"`
MotionsRecommendationsBy string `json:"motions_recommendations_by"`
MotionsEnableSideboxOnProjector bool `json:"motions_enable_sidebox_on_projector"`
MotionsLineLength int `json:"motions_line_length"`
Expand Down
40 changes: 3 additions & 37 deletions internal/projector/slide/motion.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ func motionStateFromMap(in map[string]json.RawMessage) (*dbMotionState, error) {
return &ms, nil
}

type dbMotionStatuteParagraph struct {
Title string `json:"title"`
Text string `json:"text"`
}

type dbMotionChangeRecommendation struct {
ID int `json:"id"`
Rejected bool `json:"rejected"`
Expand Down Expand Up @@ -72,7 +67,6 @@ type leadMotionType struct {
type dbMotionWork struct {
MeetingID int `json:"meeting_id"`
LeadMotionID int `json:"lead_motion_id"`
StatuteParagraphID int `json:"statute_paragraph_id"`
ChangeRecommendationIDS []int `json:"change_recommendation_ids"`
AmendmentIDS []int `json:"amendment_ids"`
SubmitterIDS []int `json:"submitter_ids"`
Expand All @@ -95,7 +89,6 @@ type dbMotion struct {
LineNumbering string `json:"line_numbering"`
AmendmentParagraph json.RawMessage `json:"amendment_paragraphs,omitempty"`
LeadMotion *leadMotionType `json:"lead_motion,omitempty"`
BaseStatute *dbMotionStatuteParagraph `json:"base_statute,omitempty"`
ChangeRecommendations []dbMotionChangeRecommendation `json:"change_recommendations"`
Amendments []amendmentsType `json:"amendments,omitempty"`
RecommendationReferencingMotions []json.RawMessage `json:"recommendation_referencing_motions,omitempty"`
Expand Down Expand Up @@ -136,7 +129,6 @@ func Motion(store *projector.SlideStore) {
"motions_enable_reason_on_projector",
"motions_show_referring_motions",
"motions_enable_recommendation_on_projector",
"motions_statute_recommendations_by",
"motions_recommendations_by",
"motions_enable_sidebox_on_projector",
"motions_line_length",
Expand Down Expand Up @@ -176,9 +168,6 @@ func Motion(store *projector.SlideStore) {
"start_line_number",
"additional_submitter",
}
if meeting.MotionsEnableTextOnProjector {
fetchFields = append(fetchFields, "text", "amendment_paragraphs", "statute_paragraph_id")
}
if meeting.MotionsEnableReasonOnProjector {
fetchFields = append(fetchFields, "reason")
}
Expand All @@ -204,10 +193,6 @@ func Motion(store *projector.SlideStore) {
return nil, fmt.Errorf("fillLeadMotion: %w", err)
}

if err := fillBaseStatute(ctx, fetch, motion); err != nil {
return nil, fmt.Errorf("fillBaseStatute: %w", err)
}

if err := fillChangeRecommendations(ctx, fetch, motion); err != nil {
return nil, fmt.Errorf("fillChangeRecommendations: %w", err)
}
Expand Down Expand Up @@ -315,23 +300,6 @@ func fillLeadMotion(ctx context.Context, fetch *datastore.Fetcher, motion *dbMot
return nil
}

func fillBaseStatute(ctx context.Context, fetch *datastore.Fetcher, motion *dbMotion) error {
if motion.MotionWork.StatuteParagraphID == 0 {
return nil
}
data := fetch.Object(ctx, fmt.Sprintf("motion_statute_paragraph/%d", motion.MotionWork.StatuteParagraphID), "title", "text")
bs, err := json.Marshal(data)
if err != nil {
return fmt.Errorf("encoding BaseStatute data: %w", err)
}
var mo dbMotionStatuteParagraph
if err := json.Unmarshal(bs, &mo); err != nil {
return fmt.Errorf("decoding BaseStatute data: %w", err)
}
motion.BaseStatute = &mo
return nil
}

func fillChangeRecommendations(ctx context.Context, fetch *datastore.Fetcher, motion *dbMotion) error {
if len(motion.MotionWork.ChangeRecommendationIDS) == 0 {
return nil
Expand Down Expand Up @@ -411,11 +379,9 @@ func fillRecommendationLabelEtc(ctx context.Context, fetch *datastore.Fetcher, t
}

}
if motion.MotionWork.StatuteParagraphID > 0 {
motion.Recommender = meeting.MotionsStatuteRecommendationsBy
} else {
motion.Recommender = meeting.MotionsRecommendationsBy
}

motion.Recommender = meeting.MotionsRecommendationsBy

return nil
}

Expand Down
160 changes: 1 addition & 159 deletions internal/projector/slide/motion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func TestMotion(t *testing.T) {
motions_enable_reason_on_projector: false
motions_show_referring_motions: false
motions_enable_recommendation_on_projector: false
motions_statute_recommendations_by: Meeting MotionsStatuteRecommendations
motions_recommendations_by: Meeting not used variant
motions_enable_sidebox_on_projector: true
motions_line_length: 85
Expand Down Expand Up @@ -146,10 +145,7 @@ func TestMotion(t *testing.T) {
username: user12
13:
username: user13
motion_statute_paragraph:
1:
title: MotionStatuteParagraph1 title
text: <p>MotionStatuteParagraph1 text html</p>
motion_change_recommendation:
1:
internal: false
Expand Down Expand Up @@ -292,160 +288,6 @@ func TestMotion(t *testing.T) {
}
]
}
`,
},
{
"motion including conditional fields",
[]byte(`{"mode":"final"}`),
changeData(data, map[dskey.Key][]byte{
dskey.MustKey("meeting/1/motions_enable_text_on_projector"): []byte(`true`),
dskey.MustKey("meeting/1/motions_enable_reason_on_projector"): []byte(`true`),
dskey.MustKey("meeting/1/motions_show_referring_motions"): []byte(`true`),
dskey.MustKey("meeting/1/motions_enable_recommendation_on_projector"): []byte(`true`),
dskey.MustKey("motion/1/lead_motion_id"): []byte(`2`),
dskey.MustKey("motion/1/statute_paragraph_id"): []byte(`1`),
}),
`{
"id":1,
"title":"Motion Title 1",
"number":"MNr1234",
"submitters":[
"user11",
"user12",
"user13"
],
"show_sidebox": true,
"line_length": 85,
"start_line_number": 24,
"preamble": "The assembly may decide",
"line_numbering": "outside",
"amendment_paragraphs":{
"1":"amendmentParagraph1",
"2":"amendmentParagraph2"
},
"change_recommendations":[
{
"id": 1,
"rejected": true,
"type": "replacement",
"other_description": "Other Description1",
"line_from": 1,
"line_to": 3,
"text": "<p>text1 HTML</p>",
"creation_time": 12345
},
{
"id": 3,
"rejected": false,
"type": "insertion",
"other_description": "Other Description3",
"line_from": 5,
"line_to": 5,
"text": "<p>text3 HTML</p>",
"creation_time": 32345
}
],
"amendments":[
{
"id": 3,
"title": "Amendment3 title",
"number": "Amendment3 123",
"amendment_paragraphs":{
"31":"amendmentParagraph31",
"32":"amendmentParagraph32"
},
"change_recommendations":[
{
"id": 4,
"rejected": true,
"type": "replacement",
"other_description": "ChangeRecommendation4 for amendment3",
"line_from": 4,
"line_to": 5,
"text": "<p>text4 HTML</p>",
"creation_time": 42345
}
],
"merge_amendment_into_final": "do_merge",
"merge_amendment_into_diff": "do_merge"
},
{
"id": 4,
"title": "Amendment4 title",
"number": "Amendment4 4123",
"amendment_paragraphs": null,
"change_recommendations": null,
"merge_amendment_into_final": "undefined",
"merge_amendment_into_diff": "undefined"
},
{
"id": 5,
"title": "Amendment5 title",
"number": "Amendment5 5123",
"amendment_paragraphs": null,
"change_recommendations": null,
"merge_amendment_into_final": "undefined",
"merge_amendment_into_diff": "do_merge"
},
{
"id": 6,
"title": "Amendment6 title",
"number": "Amendment6 6123",
"amendment_paragraphs": null,
"change_recommendations": null,
"merge_amendment_into_final": "undefined",
"merge_amendment_into_diff": "undefined"
}
],
"text":"<p>Motion1 Text HTML</p>",
"reason": "<p>Motion1 reason HTML</p>",
"modified_final_version":"<p>Motion1 modifiedFinalVersion HTML</p>",
"lead_motion":{
"title":"Lead Motion Title",
"number":"Lead Motion 111",
"text":"<p>Lead Motion Text HTML</p>",
"start_line_number": 24
},
"base_statute":{
"title":"MotionStatuteParagraph1 title",
"text":"<p>MotionStatuteParagraph1 text html</p>"
},
"recommendation_referencing_motions":[
{
"agenda_item_number":"ItemNr Motion7",
"collection":"motion",
"content_object_id":"motion/7",
"title": "ReferencedInMotionRecommendationExtension7 title",
"number": "RIMRE7 number"
},
{
"agenda_item_number":"ItemNr Motion8",
"collection":"motion",
"content_object_id":"motion/8",
"title": "ReferencedInMotionRecommendationExtension8 title",
"number": "RIMRE8 number"
}
],
"recommendation_label":"RecommendationLabel_state4",
"recommendation_extension":"RecommendationExtension_motion1",
"recommendation_referenced_motions":{
"motion/9":{
"agenda_item_number":"ItemNr Motion9",
"collection":"motion",
"content_object_id":"motion/9",
"title": "RecommendationExtensionReferenceMotion9 title",
"number": "RecommendationExtensionReferenceMotion9 number"
},
"motion/10":{
"agenda_item_number":"ItemNr Motion10",
"collection":"motion",
"content_object_id":"motion/10",
"title": "RecommendationExtensionReferenceMotion10 title",
"number": "RecommendationExtensionReferenceMotion10 number"
}
},
"recommender": "Meeting MotionsStatuteRecommendations"
}
`,
},
} {
Expand Down
1 change: 0 additions & 1 deletion internal/restrict/collection/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ var collectionMap = map[string]Restricter{
MotionChangeRecommendation{}.Name(): MotionChangeRecommendation{},
MotionEditor{}.Name(): MotionEditor{},
MotionState{}.Name(): MotionState{},
MotionStatuteParagraph{}.Name(): MotionStatuteParagraph{},
MotionComment{}.Name(): MotionComment{},
MotionCommentSection{}.Name(): MotionCommentSection{},
MotionSubmitter{}.Name(): MotionSubmitter{},
Expand Down
44 changes: 0 additions & 44 deletions internal/restrict/collection/motion_statute_paragraph.go

This file was deleted.

29 changes: 0 additions & 29 deletions internal/restrict/collection/motion_statute_paragraph_test.go

This file was deleted.

Loading

0 comments on commit d2da57d

Please sign in to comment.