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

wip: postupload #813

Draft
wants to merge 68 commits into
base: main
Choose a base branch
from
Draft

wip: postupload #813

wants to merge 68 commits into from

Conversation

krmax44
Copy link
Member

@krmax44 krmax44 commented Aug 12, 2024

No description provided.

(0, _("I have received the letter")),
(1, _("I have sent the letter")),
),
coerce=lambda x: bool(int(x)),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that safe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsafe in what way? (I just copied it from elsewhere in the code.)

steps: Array
})

const progressDesktop = computed(() => props.step / (props.steps.length - 1))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a bit clearer: this one starts from zero, the other one from one

*/

// this could possibly move to lib/vue-helper.ts
const vBsTooltip = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great idea! could also be a helper component

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried it quickly; failed because of vue2/3 mixture... will retry at some point

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stepHistory.push(nextStep || getNextStep())
}

const gotoValid = computed(() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should use a proper state machine for this, like xstate? this is very confusing to me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! having a visual representation will be very beneficial

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plan of attack:

  1. attach the current implementation as-is to history api (like .../#1100')
  2. see if xstate can a. handle our state machine part and b. work with hash-history
  3. if not, consider a lightweight, handrolled state machine implementation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe vue-router could also work for this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but doesn't vue-router also always expose the state to the back-button, leaving states reachable which shouldn't be? resp., necessitate complex navigation guards, which are state-machine-like...

froide/foirequest/forms/message.py Outdated Show resolved Hide resolved
message = FoiMessage(request=foirequest, kind=MessageKind.POST)
# hack, prevent: null value in column "timestamp" of relation "foirequest_foimessage" violates not-null constraint
# this will be set to "proper" (noon) when finally submitted
message.timestamp = datetime.datetime.now()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this lead to timezone problems?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof, hard to tell (for me). i think it shouldn't, because, as stated in the comment, it's a temporary non-null replacement, that shouldn't exist for too long.
but speaking of timezone problems, registered_mail_date from your other comment might cause problems? it's supposed to be a "timeless" date, so it gets set to midnight. i found date field logic hard to understand...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krmax44 suggest adding a constraint that allows this field to be nullable as long is_draft UNLESS this is the only timestamp/created_at-ish info

)
return redirect(url)
else:
if is_fetch(request):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to filter on accept header?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. resolved by 998ad92

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, unresolved -- a normal form.submit sends Accept: ...,*/* so it does accepts("application/json"), so this is no way to distinguish from a fetch. I'll revert this unless you know a better solution

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krmax44 will look into turning this into a proper api endpoint

froide/helper/form_utils.py Outdated Show resolved Hide resolved
def serialize_extra(obj):
if isinstance(obj, Decimal):
return {
"__Decimal": True,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a nice way or should we add a tag field that specifies the type of the object serialized here? e.g. something like

Suggested change
"__Decimal": True,
"__type__": "__Decimal",

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like your suggestion; tbh i don't use the type info anywhere - i just felt dirty not doing anything :) yagni?

@bikubi bikubi force-pushed the bikubi/postupload-wip branch 3 times, most recently from 764ed6a to 14527b0 Compare September 23, 2024 15:40
@@ -566,6 +566,8 @@ def is_pkce_required(client_id):
"about": "/about/",
"help": "/help/",
"throttled": "/help/",
# TODO english?
"help_postupload_redaction": "/hilfe/plain/funktionen-der-plattform/schwaerzungen-durchfuehren/",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's there: https://github.com/okfde/fragdenstaat_de/blob/bikubi/postupload-wip3/fragdenstaat_de/settings/base.py#L726

but since post-upload.vue is part of froide, and this help url is kind of expected (short of hard coded), isn't it weird to leave it undefined, then? or should the text which contains this link be also moved to the theme repo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: split this up into smaller views; move the larger logic to a javascript module/class

}

/* bootstrap doesn't provide this responsive position class out of the box
* (it could be compiled in with utils/helpers)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done! wasn't sure if this one case was worth the overhead, but also hadn't seen that we already have utilities configured.. thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants