Forms¶
Form management for the Django dynamic site app
Classes:
Name | Description |
---|---|
InstallationForm |
placeholder |
TemplateSelectForm |
placeholder |
PlaceholdersForm |
placeholder |
DocumentUpdateForm |
placeholder |
LogHazardForm |
placeholder |
HazardCommentForm |
placeholder |
UploadToGithubForm |
placeholder |
Functions:
Name | Description |
---|---|
validated_response |
placeholder |
md_files |
placeholder |
DocumentNewForm
¶
Bases: Form
Source code in app/dcsp/app/forms.py
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
|
__init__(project_id, *args, **kwargs)
¶
Initialisation of the selection field
Searches the docs folder and searches for markdown files, noting the any subfolders. These are then provided as a selection field.
Source code in app/dcsp/app/forms.py
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 |
|
clean()
¶
Checks if a valid path
Source code in app/dcsp/app/forms.py
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
|
DocumentUpdateForm
¶
Bases: Form
Text edit area of selected markdown file
Provides the raw markdown for the selected file.
Fields
document_name: TODO document_markdown: raw markdown of the file with placeholders evident in double curley brackets (eg {{ placeholder }})
Source code in app/dcsp/app/forms.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 |
|
__init__(project_id, document_name='', *args, **kwargs)
¶
Initialisation of the selection field
Searches the docs folder and searches for markdown files, noting the any subfolders. These are then provided as a selection field.
Source code in app/dcsp/app/forms.py
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 |
|
clean()
¶
Source code in app/dcsp/app/forms.py
794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 |
|
EntryUpdateForm
¶
Bases: Form
Source code in app/dcsp/app/forms.py
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 |
|
__init__(project_id, entry_type, *args, **kwargs)
¶
Initialise the entry form
Gets available entry labels for entry form
Fields
horizontal_line: a horizontal line across the web page. TODO:TODO
Source code in app/dcsp/app/forms.py
836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 |
|
HazardCommentForm
¶
Bases: Form
Form for adding comments to a preexisting hazard
A simple form to add a comment to a pre-existing hazard.
Fields
comment: a new comment for the hazard.
Source code in app/dcsp/app/forms.py
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 |
|
PlaceholdersForm
¶
Bases: Form
Creates fields for all available placeholders
Searches through the docs folder in mkdocs for markdown files. If a placeholder is found, then this is made available for the user to provide a value for.
Methods:
Name | Description |
---|---|
clean |
placeholder |
Fields
[Automatically created]
Source code in app/dcsp/app/forms.py
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 |
|
__init__(project_id, *args, **kwargs)
¶
Find placeholders and initialises web app fields
Searches for placeholders in markdown files in doc folder and creates fields for each.
Source code in app/dcsp/app/forms.py
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
|
clean()
¶
Checks placeholders for invalid characters
Current invalid characters are "{}"'"
Source code in app/dcsp/app/forms.py
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 |
|
ProjectSetupInitialForm
¶
Bases: Form
Setup a project
Source code in app/dcsp/app/forms.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
clean()
¶
Source code in app/dcsp/app/forms.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
ProjectSetupStepTwoForm
¶
Bases: Form
ProjectSetupStepTwoForm
Fields
project_name_import_start_anew: name of the project
Source code in app/dcsp/app/forms.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
__init__(*args, **kwargs)
¶
Initialise the fields for the second step of project setup
Source code in app/dcsp/app/forms.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
TemplateSelectForm
¶
Bases: Form
Template selection form
Provides available templates.
Fields
template_choice: pick the template to use for hazard documentation.
Source code in app/dcsp/app/forms.py
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
|
__init__(project_id, *args, **kwargs)
¶
Initialise with available templates
Searches in the templates folder for template sub-folders and provides these as options in a selection field for the user.
Source code in app/dcsp/app/forms.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
|
UploadToGithubForm
¶
Bases: Form
Add comment for commit
Form to add comment to then add to commit and then push to GitHub
Fields
comment
Source code in app/dcsp/app/forms.py
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 |
|
heading_level(heading)
¶
Determine the heading level
Parameters:
Name | Type | Description | Default |
---|---|---|---|
heading
|
str
|
heading to check |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the heading css class |
Source code in app/dcsp/app/forms.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
md_files(project_id)
¶
Finds markdown files
Looks for markdown files in MKDOCS_PATH. Returns a list of paths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id
|
int
|
project database id number |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list[tuple[Any, Any]]
|
list of paths of markdown files relative to MKDOCS_PATH |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
if the docs location is not a valid directory |
Source code in app/dcsp/app/forms.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
validated_response(self, field, valid, error_message)
¶
A general function to create form validation results
Provides the field class and error messages to work with Bootstrap.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field
|
str
|
name of field. |
required |
valid
|
bool
|
if the validation of the field passes, True = passes, False = does not pass. |
required |
error_message
|
str
|
message to display if data does not pass validation. |
required |
Source code in app/dcsp/app/forms.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|