From 7de778a57e71a72deed795915915c759d96f41cb Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Mon, 16 Mar 2020 22:35:48 +0000 Subject: [PATCH] Work on event creation form --- RIGS/rigboard.py | 1 + RIGS/static/js/asteroids.min.js | 1 + RIGS/static/js/interaction.js | 1 + RIGS/templates/calendar.html | 31 +- RIGS/templates/event_form.html | 384 +++--------------- RIGS/templates/organisation_list.html | 14 +- .../partials/contact_details_form.html | 74 ++++ .../partials/event_details_form.html | 171 ++++++++ RIGS/templates/venue_list.html | 14 +- RIGS/urls.py | 8 +- assets/templates/partials/render_field.html | 16 - gulpfile.js | 5 +- 12 files changed, 333 insertions(+), 387 deletions(-) create mode 100644 RIGS/static/js/asteroids.min.js create mode 100644 RIGS/static/js/interaction.js create mode 100644 RIGS/templates/partials/contact_details_form.html create mode 100644 RIGS/templates/partials/event_details_form.html delete mode 100644 assets/templates/partials/render_field.html diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 2da0eac7..1b196423 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -104,6 +104,7 @@ class EventRA(generic.base.RedirectView): class EventCreate(generic.CreateView): model = models.Event form_class = forms.EventForm + template_name = 'event_form.html' def get_context_data(self, **kwargs): context = super(EventCreate, self).get_context_data(**kwargs) diff --git a/RIGS/static/js/asteroids.min.js b/RIGS/static/js/asteroids.min.js new file mode 100644 index 00000000..035d9cf8 --- /dev/null +++ b/RIGS/static/js/asteroids.min.js @@ -0,0 +1 @@ +!function(){function Asteroids(){function Vector(e,t){"Object"==typeof e?(this.x=e.x,this.y=e.y):(this.x=e,this.y=t)}function Line(e,t){this.p1=e,this.p2=t}window.ASTEROIDS||(window.ASTEROIDS={enemiesKilled:0}),Vector.prototype={cp:function(){return new Vector(this.x,this.y)},mul:function(e){return this.x*=e,this.y*=e,this},mulNew:function(e){return new Vector(this.x*e,this.y*e)},add:function(e){return this.x+=e.x,this.y+=e.y,this},addNew:function(e){return new Vector(this.x+e.x,this.y+e.y)},sub:function(e){return this.x-=e.x,this.y-=e.y,this},subNew:function(e){return new Vector(this.x-e.x,this.y-e.y)},rotate:function(e){var t=this.x,i=this.y;return this.x=t*Math.cos(e)-Math.sin(e)*i,this.y=t*Math.sin(e)+Math.cos(e)*i,this},rotateNew:function(e){return this.cp().rotate(e)},setAngle:function(e){var t=this.len();return this.x=Math.cos(e)*t,this.y=Math.sin(e)*t,this},setAngleNew:function(e){return this.cp().setAngle(e)},setLength:function(e){var t=this.len();return t?this.mul(e/t):this.x=this.y=e,this},setLengthNew:function(e){return this.cp().setLength(e)},normalize:function(){var e=this.len();return this.x/=e,this.y/=e,this},normalizeNew:function(){return this.cp().normalize()},angle:function(){return Math.atan2(this.y,this.x)},collidesWith:function(e){return this.x>e.x&&this.y>e.y&&this.x-.005?0:e},is:function(e){return"object"==typeof e&&this.x==e.x&&this.y==e.y},toString:function(){return"[Vector("+this.x+", "+this.y+") angle: "+this.angle()+", length: "+this.len()+"]"}},Line.prototype={shift:function(e){this.p1.add(e),this.p2.add(e)},intersectsWithRect:function(e){var t=new Vector(e.x,e.y+e.height),i=new Vector(e.x,e.y),s=new Vector(e.x+e.width,e.y+e.height),n=new Vector(e.x+e.width,e.y);return this.p1.x>t.x&&this.p1.xn.y&&this.p2.x>t.x&&this.p2.xn.y||!!this.intersectsLine(new Line(i,t))||!!this.intersectsLine(new Line(t,s))||!!this.intersectsLine(new Line(i,n))||!!this.intersectsLine(new Line(n,s))},intersectsLine:function(e){var t=this.p1,i=this.p2,s=e.p1,n=e.p2,a=(n.y-s.y)*(i.x-t.x)-(n.x-s.x)*(i.y-t.y),o=(n.x-s.x)*(t.y-s.y)-(n.y-s.y)*(t.x-s.x),h=(i.x-t.x)*(t.y-s.y)-(i.y-t.y)*(t.x-s.x);if(0==a)return!1;var r=o/a,l=h/a;return r>=0&&r<=1&&l>=0&&l<=1}};var that=this,isIE=!!window.ActiveXObject,isIEQuirks=isIE&&"BackCompat"==document.compatMode,w=document.documentElement.clientWidth,h=document.documentElement.clientHeight;isIEQuirks&&(w=document.body.clientWidth,h=document.body.clientHeight);var playerWidth=20,playerHeight=30,playerVerts=[[-1*playerHeight/2,-1*playerWidth/2],[-1*playerHeight/2,playerWidth/2],[playerHeight/2,0]],ignoredTypes=["HTML","HEAD","BODY","SCRIPT","TITLE","META","STYLE","LINK"];window.ActiveXObject&&(ignoredTypes=["HTML","HEAD","BODY","SCRIPT","TITLE","META","STYLE","LINK","SHAPE","LINE","GROUP","IMAGE","STROKE","FILL","SKEW","PATH","TEXTPATH","INS"]);var hiddenTypes=["BR","HR"],FPS=50,acc=300,maxSpeed=600,rotSpeed=360,bulletSpeed=700,particleSpeed=400,timeBetweenFire=150,timeBetweenBlink=250,timeBetweenEnemyUpdate=isIE?1e4:2e3,bulletRadius=2,maxParticles=isIE?20:40,maxBullets=isIE?10:20,createFlames,rWidth,rIncrease,yWidth,yIncrease,halfR,halfY,halfPlayerHeight;function updateEnemyIndex(){for(var e,t=0;e=that.enemies[t];t++)removeClass(e,"ASTEROIDSYEAHENEMY");var i,s=document.body.getElementsByTagName("*");for(that.enemies=[],t=0;i=s[t];t++)-1==indexOf(ignoredTypes,i.tagName.toUpperCase())&&"g_vml_"!=i.prefix&&hasOnlyTextualChildren(i)&&"ASTEROIDSYEAH"!=i.className&&i.offsetHeight>0&&(i.aSize=size(i),that.enemies.push(i),addClass(i,"ASTEROIDSYEAHENEMY"),i.aAdded||(i.aAdded=!0,that.totalEnemies++))}function radians(e){return.0174532925*e}function degrees(e){return 57.2957795*e}function random(e,t){return Math.floor(Math.random()*(t+1)+e)}function code(e){var t={up:38,down:40,left:37,right:39,esc:27};return t[e]?t[e]:e.charCodeAt(0)}function boundsCheck(e){e.x>w?e.x=0:e.x<0&&(e.x=w),e.y>h?e.y=0:e.y<0&&(e.y=h)}function size(e){var t=e,i=0,s=0;do{i+=t.offsetLeft||0,s+=t.offsetTop||0,t=t.offsetParent}while(t);return{x:i,y:s,width:e.offsetWidth||10,height:e.offsetHeight||10}}function addEvent(e,t,i){e.addEventListener?e.addEventListener(t,i,!1):e.attachEvent&&(e["e"+t+i]=i,e[t+i]=function(){e["e"+t+i](window.event)},e.attachEvent("on"+t,e[t+i]))}function removeEvent(e,t,i){e.removeEventListener?e.removeEventListener(t,i,!1):e.detachEvent&&(e.detachEvent("on"+t,e[t+i]),e[t+i]=null,e["e"+t+i]=null)}function arrayRemove(e,t,i){var s=e.slice((i||t)+1||e.length);return e.length=t<0?e.length+t:t,e.push.apply(e,s)}function applyVisibility(e){for(var t,i=0;t=window.ASTEROIDSPLAYERS[i];i++)t.gameContainer.style.visibility=e}function getElementFromPoint(e,t){applyVisibility("hidden");var i=document.elementFromPoint(e,t);return i?(3==i.nodeType&&(i=i.parentNode),applyVisibility("visible"),i):(applyVisibility("visible"),!1)}function addParticles(e){for(var t=(new Date).getTime(),i=maxParticles,s=0;s0&&e.offsetHeight>0)return!1;if(-1!=indexOf(hiddenTypes,e.tagName))return!0;if(0==e.offsetWidth&&0==e.offsetHeight)return!1;for(var t=0;t50&&(createFlames(),this.updated.flame=t),this.scrollPos.x=window.pageXOffset||document.documentElement.scrollLeft,this.scrollPos.y=window.pageYOffset||document.documentElement.scrollTop,this.keysPressed[code("up")]||this.keysPressed[code("W")]?(this.vel.add(this.dir.mulNew(acc*i)),s=!0):this.vel.mul(.96),(this.keysPressed[code("left")]||this.keysPressed[code("A")])&&(e=!0,this.dir.rotate(radians(rotSpeed*i*-1))),(this.keysPressed[code("right")]||this.keysPressed[code("D")])&&(e=!0,this.dir.rotate(radians(rotSpeed*i))),this.keysPressed[code(" ")]&&t-this.firedAt>timeBetweenFire&&(this.bullets.unshift({dir:this.dir.cp(),pos:this.pos.cp(),startVel:this.vel.cp(),cameAlive:t}),this.firedAt=t,this.bullets.length>maxBullets&&this.bullets.pop()),this.keysPressed[code("B")]?(this.updated.enemies||(updateEnemyIndex(),this.updated.enemies=!0),e=!0,this.updated.blink.time+=1e3*i,this.updated.blink.time>timeBetweenBlink&&(this.toggleBlinkStyle(),this.updated.blink.time=0)):this.updated.enemies=!1,this.keysPressed[code("esc")])destroy.apply(this);else{this.vel.len()>maxSpeed&&this.vel.setLength(maxSpeed),this.pos.add(this.vel.mulNew(i)),this.pos.x>w?(window.scrollTo(this.scrollPos.x+50,this.scrollPos.y),this.pos.x=0):this.pos.x<0&&(window.scrollTo(this.scrollPos.x-50,this.scrollPos.y),this.pos.x=w),this.pos.y>h?(window.scrollTo(this.scrollPos.x,this.scrollPos.y+.75*h),this.pos.y=0):this.pos.y<0&&(window.scrollTo(this.scrollPos.x,this.scrollPos.y-.75*h),this.pos.y=h);for(var n=this.bullets.length-1;n>=0;n--)if(t-this.bullets[n].cameAlive>2e3)this.bullets.splice(n,1),e=!0;else{var a=this.bullets[n].dir.setLengthNew(bulletSpeed*i).add(this.bullets[n].startVel.mulNew(i));this.bullets[n].pos.add(a),boundsCheck(this.bullets[n].pos);var o=getElementFromPoint(this.bullets[n].pos.x,this.bullets[n].pos.y);o&&o.tagName&&-1==indexOf(ignoredTypes,o.tagName.toUpperCase())&&hasOnlyTextualChildren(o)&&"ASTEROIDSYEAH"!=o.className&&(didKill=!0,addParticles(this.bullets[n].pos),this.dying.push(o),this.bullets.splice(n,1))}if(this.dying.length){for(n=this.dying.length-1;n>=0;n--)try{this.dying[n].parentNode&&window.ASTEROIDS.enemiesKilled++,this.dying[n].parentNode.removeChild(this.dying[n])}catch(e){}setScore(),this.dying=[]}for(n=this.particles.length-1;n>=0;n--)this.particles[n].pos.add(this.particles[n].dir.mulNew(particleSpeed*i*Math.random())),t-this.particles[n].cameAlive>1e3&&(this.particles.splice(n,1),e=!0);isIEQuirks&&(this.gameContainer.style.left=this.canvas.style.left=document.documentElement.scrollLeft+"px",this.gameContainer.style.top=this.canvas.style.top=document.documentElement.scrollTop+"px",this.navigation.style.right="10px",this.navigation.style.top=document.documentElement.scrollTop+document.body.clientHeight-this.navigation.clientHeight-10+"px"),(e||0!=this.bullets.length||0!=this.particles.length||!this.pos.is(this.lastPos)||this.vel.len()>0)&&(this.ctx.clear(),this.ctx.drawPlayer(),s&&this.ctx.drawFlames(that.flame),this.bullets.length&&this.ctx.drawBullets(this.bullets),this.particles.length&&this.ctx.drawParticles(this.particles)),this.lastPos=this.pos}};var updateFunc=function(){try{that.update.call(that)}catch(e){throw clearInterval(interval),e}},interval=setInterval(updateFunc,1e3/FPS);function destroy(){removeEvent(document,"keydown",eventKeydown),removeEvent(document,"keypress",eventKeypress),removeEvent(document,"keyup",eventKeyup),removeEvent(window,"resize",eventResize),isRunning=!1,removeStylesheet("ASTEROIDSYEAHSTYLES"),removeClass(document.body,"ASTEROIDSYEAH"),this.gameContainer.parentNode.removeChild(this.gameContainer)}}if(window.ASTEROIDSPLAYERS||(window.ASTEROIDSPLAYERS=[]),window.ActiveXObject&&!document.createElement("canvas").getContext){try{var xamlScript=document.createElement("script");xamlScript.setAttribute("type","text/xaml"),xamlScript.textContent='',document.getElementsByTagName("head")[0].appendChild(xamlScript)}catch(e){}var script=document.createElement("script");script.setAttribute("type","text/javascript"),script.onreadystatechange=function(){"loaded"!=script.readyState&&"complete"!=script.readyState||"undefined"!=typeof G_vmlCanvasManager&&(window.ASTEROIDSPLAYERS[window.ASTEROIDSPLAYERS.length]=new Asteroids)},script.src="http://erkie.github.com/excanvas.js",document.getElementsByTagName("head")[0].appendChild(script)}else window.ASTEROIDSPLAYERS[window.ASTEROIDSPLAYERS.length]=new Asteroids}(); \ No newline at end of file diff --git a/RIGS/static/js/interaction.js b/RIGS/static/js/interaction.js new file mode 100644 index 00000000..3b409c13 --- /dev/null +++ b/RIGS/static/js/interaction.js @@ -0,0 +1 @@ +function setupItemTable(t){objectitems=JSON.parse(t),$.each(objectitems,(function(t,e){objectitems[t]=JSON.parse(e)})),newitem=-1}function nl2br(t,e){return(t+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+(e||void 0===e?"
":"
")+"$2")}function escapeHtml(t){return $("
").text(t).html()}function updatePrices(){var t=0;for(var e in objectitems){var i=objectitems[e].fields,a=i.cost*i.quantity;$("#item-"+e+" .sub-total").html(parseFloat(a).toFixed(2)).data("subtotal",a),t+=Number(a)}$("#sumtotal").text(parseFloat(t).toFixed(2));var o=t*Number($("#vat-rate").data("rate"));$("#vat").text(parseFloat(o).toFixed(2)),$("#total").text(parseFloat(t+o).toFixed(2))}$("#item-table").on("click",".item-delete",(function(){delete objectitems[$(this).data("pk")],$("#item-"+$(this).data("pk")).remove(),updatePrices()})),$("#item-table").on("click",".item-add",(function(){$("#item-form").data("pk",newitem),$("#item_name").val(""),$("#item_description").val(""),$("#item_quantity").val(""),$("#item_cost").val(""),$($(this).data("target")).modal("show")})),$("#item-table").on("click",".item-edit",(function(){var t=$(this).data("pk");$("#item-form").data("pk",t);var e=objectitems[t].fields;$("#item_name").val(e.name),$("#item_description").val(e.description),$("#item_quantity").val(e.quantity),$("#item_cost").val(e.cost),$($(this).data("target")).modal("show")})),$("body").on("submit","#item-form",(function(t){t.preventDefault();var e,i=$(this).data("pk");if($("#itemModal").modal("hide"),i==newitem--){(e=new Object).name=$("#item_name").val(),e.description=$("#item_description").val(),e.cost=$("#item_cost").val(),e.quantity=$("#item_quantity").val();var a=0;for(item in objectitems)a++;e.order=a,objectitems[i]=new Object,objectitems[i].fields=e,$("#new-item-row").clone().attr("id","item-"+i).data("pk",i).appendTo("#item-table-body"),$("#item-"+i+" .item-delete, #item-"+i+" .item-edit").data("pk",i)}else(e=objectitems[i].fields).name=$("#item_name").val(),e.description=$("#item_description").val(),e.cost=$("#item_cost").val(),e.quantity=$("#item_quantity").val(),objectitems[i].fields=e;$row=$("#item-"+i),$row.find(".name").html(escapeHtml(e.name)),$row.find(".description").html(nl2br(escapeHtml(e.description))),$row.find(".cost").html(parseFloat(e.cost).toFixed(2)),$row.find(".quantity").html(e.quantity),updatePrices()})),$("body").on("submit",".itemised_form",(function(t){$("#id_items_json").val(JSON.stringify(objectitems))}));var fixHelper=function(t,e){return e.children().each((function(){$(this).width($(this).width())})),e};$("#item-table tbody").sortable({helper:fixHelper,update:function(t,e){info=$(this).sortable("toArray"),itemorder=new Array,$.each(info,(function(t,e){pk=$("#"+e).data("pk"),objectitems[pk].fields.order=t}))}}); \ No newline at end of file diff --git a/RIGS/templates/calendar.html b/RIGS/templates/calendar.html index 0af40335..3bb58ecb 100644 --- a/RIGS/templates/calendar.html +++ b/RIGS/templates/calendar.html @@ -190,36 +190,31 @@
- -
-
+
+
- - + +
- -
+
- -
- - +
+ +
- -
- - - +
+ + +
-
-
+
{% endblock %} diff --git a/RIGS/templates/event_form.html b/RIGS/templates/event_form.html index 8ae1aef2..1200c227 100644 --- a/RIGS/templates/event_form.html +++ b/RIGS/templates/event_form.html @@ -1,12 +1,17 @@ {% extends 'base_rigs.html' %} + {% load widget_tweaks %} {% load static %} {% load multiply from filters %} -{% block title %}{% if object.pk %}Event {% if object.is_rig %}N{{ object.pk|stringformat:"05d" }}{% else %} - {{ object.pk }}{% endif %}{% else %}New Event{% endif %}{% endblock %} + +{% block title %} + {% if object.pk %} + Event {% if object.is_rig %}N{{ object.pk|stringformat:"05d" }}{% else %}{{ object.pk }}{% endif %} + {% else %}New Event{% endif %} +{% endblock %} {% block css %} - + {% endblock %} @@ -16,12 +21,11 @@ {% endblock %} {% block js %} - - +