Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
steering
Commits
a9c3c6a8
Commit
a9c3c6a8
authored
7 years ago
by
Ingo Leindecker
Browse files
Options
Downloads
Patches
Plain Diff
Added some form validation
See
#8
#20
parent
fae1ca25
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
program/admin.py
+6
-1
6 additions, 1 deletion
program/admin.py
program/templates/styles.css
+4
-0
4 additions, 0 deletions
program/templates/styles.css
pv/site_media/js/show_change.js
+56
-1
56 additions, 1 deletion
pv/site_media/js/show_change.js
with
66 additions
and
2 deletions
program/admin.py
+
6
−
1
View file @
a9c3c6a8
...
...
@@ -159,7 +159,12 @@ class ShowAdmin(admin.ModelAdmin):
class
Media
:
from
django.conf
import
settings
media_url
=
getattr
(
settings
,
'
MEDIA_URL
'
)
js
=
[
media_url
+
'
js/show_change.js
'
,]
js
=
[
media_url
+
'
js/show_change.js
'
,
media_url
+
'
js/calendar/lib/moment.min.js
'
,
]
css
=
{
'
all
'
:
(
'
/program/styles.css
'
,)
}
def
formfield_for_foreignkey
(
self
,
db_field
,
request
=
None
,
**
kwargs
):
try
:
...
...
This diff is collapsed.
Click to expand it.
program/templates/styles.css
+
4
−
0
View file @
a9c3c6a8
...
...
@@ -164,6 +164,10 @@
float
:
left
;
}
.validation-error
{
border
:
2px
solid
#ba2121
!important
;
}
.noselect
{
-webkit-touch-callout
:
none
;
/* iOS Safari */
-webkit-user-select
:
none
;
/* Safari */
...
...
This diff is collapsed.
Click to expand it.
pv/site_media/js/show_change.js
+
56
−
1
View file @
a9c3c6a8
...
...
@@ -28,6 +28,8 @@ function toggleSelects( select_elm ) {
django
.
jQuery
(
document
).
ready
(
function
()
{
moment
.
locale
(
"
de
"
);
/* Toggle selects dependent on rrule option on load */
django
.
jQuery
(
"
.field-rrule select
"
).
each
(
function
(
i
)
{
toggleSelects
(
django
.
jQuery
(
this
)
);
...
...
@@ -38,14 +40,67 @@ django.jQuery(document).ready( function() {
toggleSelects
(
django
.
jQuery
(
this
)
)
});
/* Set the until date to dstart if editing a programslot with freq 'once' */
django
.
jQuery
(
document
).
on
(
'
blur
'
,
'
.field-dstart input
'
,
function
()
{
var
ps_id
=
django
.
jQuery
(
this
).
closest
(
'
tr
'
).
attr
(
"
id
"
);
var
dstart
=
django
.
jQuery
(
this
).
val
();
//django.jQuery(this).removeClass('validation-error');
/* Set the until date to dstart if editing a programslot with freq 'once' */
if
(
django
.
jQuery
(
'
#id_
'
+
ps_id
+
'
-rrule option:selected
'
).
val
()
==
1
)
{
django
.
jQuery
(
'
#id_
'
+
ps_id
+
'
-until
'
).
show
().
val
(
dstart
).
hide
();
}
/* Check if dstart is not in the past */
/*
if( dstart != '' ) {
console.log(moment(dstart, "DD.MM.YYYY").unix());
console.log(moment().unix());
if( moment(dstart, "DD.MM.YYYY").unix() <= moment().unix() ) {
alert('Startdatum darf nicht in der Vergangenheit liegen');
django.jQuery(this).addClass('validation-error');
}
}
*/
});
django
.
jQuery
(
document
).
on
(
'
submit
'
,
'
#show_form
'
,
function
(
e
)
{
django
.
jQuery
(
'
input
'
).
removeClass
(
'
validation-error
'
);
django
.
jQuery
(
'
.field-until input
'
).
each
(
function
()
{
var
until
=
django
.
jQuery
(
this
).
val
();
var
dstart
=
django
.
jQuery
(
this
).
closest
(
'
tr
'
).
find
(
'
.field-dstart input
'
).
val
();
var
until_timestamp
=
moment
(
until
,
"
DD.MM.YYYY
"
)
/
1000
;
var
dstart_timestamp
=
moment
(
dstart
,
"
DD.MM.YYYY
"
)
/
1000
;
if
(
until
!=
''
&&
dstart
!=
''
)
{
if
(
until_timestamp
<=
dstart_timestamp
)
{
e
.
preventDefault
();
alert
(
'
Enddatum darf nicht vor dem Startdatum liegen
'
);
django
.
jQuery
(
this
).
addClass
(
'
validation-error
'
);
}
}
else
if
(
until
==
''
&&
dstart
!=
''
)
{
e
.
preventDefault
();
alert
(
'
Enddatum darf nicht leer sein
'
);
django
.
jQuery
(
this
).
addClass
(
'
validation-error
'
);
}
else
if
(
dstart
==
''
&&
until
!=
''
)
{
e
.
preventDefault
();
alert
(
'
Startdatum darf nicht leer sein
'
);
django
.
jQuery
(
this
).
closest
(
'
tr
'
).
find
(
'
.field-dstart input
'
).
addClass
(
'
validation-error
'
);
}
else
{
return
;
}
});
});
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment