I am new to flask and I created a registration form, but it is in 2 different templates-
1st template - Manually filling all the information of the user
2nd template - upload all the documents
1st template inserting values in the user table and 2nd template inserting documents into userdoc table
My question is how to commit once, like if some user fills only 1st template and leaves the 2nd then I don't want to insert that 1st table also if the user inserted 1st and 2nd then only in both tables it should insert.
The only way to store data across requests (besides using a database), is using the session.
A solution for this is to create a boolean column finished_registration in your user table, and only set it to true after the submission of the second form.
This way it's easy to setup some job to automatically delete users that has not finished registration.
Related
A user submits a form and opts in to receive a newsletter. What do I need to do to prove later that he actually did opt in?
If I store submitted form data in a db table then I am able to manually create and modify entries, so I could just change his False to True and therefore db entries don't prove anything.
I have a django website if it makes any difference.
You might want to create a table that just logs these kinds of events. The respective table might contain a datetime column, a user ID column and the Boolean value that the user_opt_in field was changed to.
I have an app where a user must be logged in to post an advertisement visible to others. How can I associate that person's unique id to that posting? Is there a way to fetch their attributes once they are signed in?
edit: each user submits a form to add the posting to the db.
I have the practice of putting triggers on every remotely important table.
Each of these tables includes 4 fields, date of insert, user who inserted, date of last change, user of last change.
Then the trigger just fills these fields with SYSDATE and APP_USER.
This way we get to see who inserted each data, and if it was later changed, we also see that.
For more important tables you should also have history, either the built in history, or a table into which each change is logged.
Each user will have a unique value in the :APP_USER substitution string.
I'm trying to track user history using a DRF backend. For that, I've created a history table that will get a new timestamped row with each update. This model is a many-to-one and has a reference to the user model by a foreign key.
Here comes the confusing part. Every time I pull up the user profile, I would like to also pull the last entry into the history table. Thus, I am considering adding a couple of columns in the table which get updated with every insert into the history table since this is probably less expensive than performing a secondary lookup each time. I'd like some feedback on this approach.
Additionally, I'm slightly confused by how to perform this update/insert combination via a single API endpoint as DRF seems to only support one-to-one CRUD.
For illustrative purposes, I'd like to achieve the following via a single API view:
User hits API endpoint with access token and update values --> Insert history table --> update user table for user's row with inserted details
Thanks!
I'm creating a custom workflow in Sharepoint 2013 with Visual Studio for the approval of the elements added to a list. It's as simple as: A user creates the element (initiator) and a different one approves it (approver).
The problem comes when I use the WriteToHistory box to leave trace of the steps. The User ID in the history item that is created is always the initiator and there's no evident way of changing it. Therefore, I thought I could replace the WriteToHistory element with a CreateListItem to create the history item and all its fields manually. When I do so, I can update all of the fields in the history item (even the WorkflowInstance value, that links this new history item with its workflow instance) but not the User ID...
I'm getting the error when the workflows runs and tries to add the new history item
Retrying last request. Next attempt scheduled in less than one minute.
Details of last request: HTTP BadRequest to <siteURL>/_vti_bin/client.svc/web/lists(guid'<workflowHistoryListGUID>')/Items
Correlation Id: 42e20e0f-61d2-4a35-9339-429d395dbdfb Instance Id: c329fba8-dbbd-4123-8411-b90a34ec8fbb
I don't know which items the last two GUIDs refer to. Additional information:
I'm setting the User ID field using its internal name. This field type is a person or group but I don't know how to create an SPUser in the workflow. I've passed a GUID and an Int32 with the user id and nothing changed
I'm not providing values for all the mandatory fields
The rest of the fields work perfectly whatever their types are: string, dates, etc.
Can anybody advise the way of customizing the User ID in the history items? Thanks
I am working on an enterprise application developed in C++ and the database is mariadb. The application processes two audit files Authentication.log and SytemDetails.log.
Audit operation requires data to be inserted into two tables called Authentication table and SystemDetails table. Auto id is the primary key for Authentication table and foreign key in SystemDetails table.
Authentication table keeps Authentication information i.e session open, login session info and SystemDetails keeps details of command executed during each session.
Right now an Authid is auto generated in database, as follows:
Authentication :AuthID,ParentAuthID,info1,Info2....
SystemDetails:sysid,authid,info1,info2....
It works as follows:
App insert one Authentication record insert wihtout parentauthid
Gets the generated auth id
Update parentauthid field of Authentication table
Finds the related system details record
Gets the auth id from database and insert the record in database table.
Problem:
DB size 200k records (Authentication table).
I found 6000 record taking more than 30 min.
After analysis, I found that step 2 and step 3 is time taking processes the database grows.
I having feeling that it is better to generate the Auth id in C++ code instead of through the database. With this change we can remove step 3 and 5.
Which is better technique to generate Auto ID for table?
Generating unique IDs in the presence of multiple users is non-trivial, and probably requires a write to permanent storage. That's slow. A client-generated GUID would be faster.
That said, when inserting a new child record you should already know the parent ID (avoids step 3) and the system details similarly should only be inserted into the DB when Authentication record exists (avoids step 4). This is true regardless of where you generate those ID's.