Skip to content

Commit

Permalink
Merge branch 'main' into prod/festapp
Browse files Browse the repository at this point in the history
  • Loading branch information
miakh committed Nov 2, 2024
2 parents d47c8dd + 5abc285 commit b46f01b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
14 changes: 7 additions & 7 deletions lib/pages/HtmlEditorPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ class _HtmlEditorPageState extends State<HtmlEditorPage> {
text: "Storno".tr(),
onPressed: _isSaving ? null : cancelPressed,
),
ButtonsHelper.bottomBarButton(
text: "Process and Save".tr(),
onPressed: _isSaving ? null : savePressed,
),
ButtonsHelper.bottomBarButton(
text: "Save".tr(),
onPressed: _isSaving ? null : saveRawPressed, // Save Raw button
onPressed: _isSaving ? null : savePressed,
),
// ButtonsHelper.bottomBarButton(
// text: "Save".tr(),
// onPressed: _isSaving ? null : saveRawPressed, // Save Raw button
// ),
],
),
),
Expand All @@ -185,8 +185,8 @@ class _HtmlEditorPageState extends State<HtmlEditorPage> {

Future<void> savePressed() async {
String? htmlTextEdited = await controller.getText();
var htmlText = HtmlHelper.removeBackgroundColor(htmlTextEdited);
htmlText = HtmlHelper.detectAndReplaceLinks(htmlTextEdited);
var htmlText = HtmlHelper.removeColor(htmlTextEdited);
htmlText = HtmlHelper.detectAndReplaceLinks(htmlText);

setState(() {
_isSaving = true;
Expand Down
8 changes: 4 additions & 4 deletions lib/pages/NewsFormPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class _NewsFormPageState extends State<NewsFormPage> {

Future<void> _sendPressed({bool isTest = false, bool process = false}) async {
var htmlContent = await _controller.getText();
htmlContent = HtmlHelper.removeBackgroundColor(htmlContent);
htmlContent = HtmlHelper.removeColor(htmlContent);
if (process == true) {
htmlContent = HtmlHelper.detectAndReplaceLinks(htmlContent);
}
Expand All @@ -76,7 +76,7 @@ class _NewsFormPageState extends State<NewsFormPage> {
}

Future<void> _processAndSendPressed() async {
_sendPressed(process: true);
_sendPressed(isTest: true, process: true);
}

@override
Expand Down Expand Up @@ -142,10 +142,10 @@ class _NewsFormPageState extends State<NewsFormPage> {
),
ButtonsHelper.bottomBarButton(
onPressed: _processAndSendPressed,
text: "Process and Send".tr(),
text: "Test",
),
ButtonsHelper.bottomBarButton(
onPressed: () => _sendPressed(),
onPressed: () => _sendPressed(process: true),
text: "Send".tr(),
),
],
Expand Down
4 changes: 2 additions & 2 deletions lib/services/HtmlHelper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class HtmlHelper {
return document.outerHtml;
}

static String removeBackgroundColor(String htmlText) {
RegExp regExp = RegExp(r'background-color\s*:\s*[^;]+;?\s*', caseSensitive: false);
static String removeColor(String htmlText) {
RegExp regExp = RegExp(r'(background-color|color)\s*:\s*[^;]+;?\s*', caseSensitive: false);
String cleanedHtmlString = htmlText.replaceAll(regExp, '');
return cleanedHtmlString;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/themeConfig.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ThemeConfig {
static Color timetableTimeLineColor(BuildContext context) => appBarColor();
static Color timetableSelectedColor(BuildContext context, Color color) => isDarkMode(context) ?
color.changeColorSaturation(0.7).changeColorLightness(0.8) :
color.changeColorSaturation(0.6).changeColorLightness(0.6)
color.changeColorSaturation(0.5).changeColorLightness(0.6)
;
static Color timetableUnselectedColor(BuildContext context, Color color) => isDarkMode(context) ?
color.changeColorSaturation(0.1).changeColorLightness(0.3) :
Expand Down
19 changes: 18 additions & 1 deletion scripts/database/users/add_user_to_occasion.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ DECLARE
occasion_open BOOLEAN;
user_data JSONB;
user_exists BOOLEAN;
user_org BIGINT;
occasion_org BIGINT;
BEGIN
-- Get the organization ID of the occasion
SELECT organization INTO occasion_org
FROM occasions
WHERE id = oc;

-- Get the organization ID of the user
SELECT organization INTO user_org
FROM user_info
WHERE id = usr;

-- Check if the user and occasion belong to the same organization
IF user_org IS DISTINCT FROM occasion_org THEN
RETURN jsonb_build_object('code', 403, 'message', 'User does not belong to the same organization as the occasion');
END IF;

-- Check if the occasion is open
SELECT is_open INTO occasion_open
FROM occasions
Expand Down Expand Up @@ -72,4 +89,4 @@ BEGIN
-- Return success code
RETURN jsonb_build_object('code', 200);
END;
$$;
$$;

0 comments on commit b46f01b

Please sign in to comment.