-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft model and autosave on Project edit form (#352)
* Use ES6 JS. Use webpack to build and transpile ES6 code. * Add scroll active menu and swipe functionality. * Sort schedule event days. * Change buttons design of the header. * Add check to find if eventday is present. * Avoid using global names. * Add support to lazy load images on the home page * Add script folder. Change to lazy load on hasgeek index page. * Sync with master. * added Makefile * Updated package-lock.json. * Fix the mui class name. * added newline * Remove default lat and lon values. * split makefile * Move view proposal btn to right. * Add support for autosave (wip) * Add autosave flag to form data. * added draft model and initial view * fixed edit endpoint * Update server response flag in error cases. * fixed creation of draft * Check form data changes before sending to backend. * Refactor checking for dirty fields of the form. * added timestamp to draft model, fixed form submit workflow * removed revision id validation * removed print statement * removed unused import * updated draft model and using composite key * Send last_revision_id to render_form * various fixes * update form post url * Update form id * fixed action url, only updating fields sent in request * Fix form field selector * Add missing semicolon. * Change to draft_revision. Use updated form review field. * added csrf check for draft autosave * fixed draft model * fixed draft delete and invalid revision ID handling * updated down revision * update down revision * fixed revision check logic * added DraftModelViewMixin * fixed draftmixin * minor fixes * changed error format * fixed multidict update * Display the error message from the server. * removed redundant statement
- Loading branch information
Bibhas
authored
Feb 19, 2019
1 parent
3e1d69c
commit 85f91cd
Showing
7 changed files
with
293 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from sqlalchemy_utils import UUIDType | ||
from werkzeug.datastructures import MultiDict | ||
from . import db, JsonDict, NoIdMixin | ||
|
||
__all__ = ['Draft'] | ||
|
||
|
||
class Draft(NoIdMixin, db.Model): | ||
"""Store for autosaved, unvalidated drafts on behalf of other models""" | ||
__tablename__ = 'draft' | ||
|
||
table = db.Column(db.UnicodeText, primary_key=True) | ||
table_row_id = db.Column(UUIDType(binary=False), primary_key=True) | ||
body = db.Column(JsonDict, nullable=False, server_default='{}') | ||
revision = db.Column(UUIDType(binary=False)) | ||
|
||
@property | ||
def formdata(self): | ||
return MultiDict(self.body.get('form', {})) | ||
|
||
@formdata.setter | ||
def formdata(self, value): | ||
if self.body is not None: | ||
self.body['form'] = value | ||
else: | ||
self.body = {'form': value} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""draft model | ||
Revision ID: 94ce3a9b7a3a | ||
Revises: c3069d33419a | ||
Create Date: 2019-02-06 20:48:34.700795 | ||
""" | ||
|
||
revision = '94ce3a9b7a3a' | ||
down_revision = 'a9cb0e1c52ed' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
from sqlalchemy_utils.types.uuid import UUIDType | ||
from coaster.sqlalchemy.columns import JsonDict | ||
|
||
|
||
def upgrade(): | ||
op.create_table('draft', | ||
sa.Column('created_at', sa.DateTime(), nullable=False), | ||
sa.Column('updated_at', sa.DateTime(), nullable=False), | ||
sa.Column('table', sa.UnicodeText(), nullable=False), | ||
sa.Column('table_row_id', UUIDType(binary=False), nullable=False), | ||
sa.Column('body', JsonDict(), server_default='{}', nullable=False), | ||
sa.Column('revision', UUIDType(binary=False), nullable=True), | ||
sa.PrimaryKeyConstraint('table', 'table_row_id') | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('draft') |