Skip to content

Commit

Permalink
Subiendo nuevos estáticos y pruebas de envío de email con errores
Browse files Browse the repository at this point in the history
  • Loading branch information
Victoriano Navarro Aguilar committed Feb 24, 2012
1 parent 75c9c0b commit bf54f7c
Show file tree
Hide file tree
Showing 11 changed files with 276 additions and 16 deletions.
Binary file added elections/static/collage_outsiders.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added elections/static/collage_samuelers2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
210 changes: 210 additions & 0 deletions elections/static/js/bootstrap-modal.js
@@ -0,0 +1,210 @@
/* =========================================================
* bootstrap-modal.js v2.0.1
* http://twitter.github.com/bootstrap/javascript.html#modals
* =========================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================= */


!function( $ ){

"use strict"

/* MODAL CLASS DEFINITION
* ====================== */

var Modal = function ( content, options ) {
this.options = options
this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
}

Modal.prototype = {

constructor: Modal

, toggle: function () {
return this[!this.isShown ? 'show' : 'hide']()
}

, show: function () {
var that = this

if (this.isShown) return

$('body').addClass('modal-open')

this.isShown = true
this.$element.trigger('show')

escape.call(this)
backdrop.call(this, function () {
var transition = $.support.transition && that.$element.hasClass('fade')

!that.$element.parent().length && that.$element.appendTo(document.body) //don't move modals dom position

that.$element
.show()

if (transition) {
that.$element[0].offsetWidth // force reflow
}

that.$element.addClass('in')

transition ?
that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
that.$element.trigger('shown')

})
}

, hide: function ( e ) {
e && e.preventDefault()

if (!this.isShown) return

var that = this
this.isShown = false

$('body').removeClass('modal-open')

escape.call(this)

this.$element
.trigger('hide')
.removeClass('in')

$.support.transition && this.$element.hasClass('fade') ?
hideWithTransition.call(this) :
hideModal.call(this)
}

}


/* MODAL PRIVATE METHODS
* ===================== */

function hideWithTransition() {
var that = this
, timeout = setTimeout(function () {
that.$element.off($.support.transition.end)
hideModal.call(that)
}, 500)

this.$element.one($.support.transition.end, function () {
clearTimeout(timeout)
hideModal.call(that)
})
}

function hideModal( that ) {
this.$element
.hide()
.trigger('hidden')

backdrop.call(this)
}

function backdrop( callback ) {
var that = this
, animate = this.$element.hasClass('fade') ? 'fade' : ''

if (this.isShown && this.options.backdrop) {
var doAnimate = $.support.transition && animate

this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.appendTo(document.body)

if (this.options.backdrop != 'static') {
this.$backdrop.click($.proxy(this.hide, this))
}

if (doAnimate) this.$backdrop[0].offsetWidth // force reflow

this.$backdrop.addClass('in')

doAnimate ?
this.$backdrop.one($.support.transition.end, callback) :
callback()

} else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in')

$.support.transition && this.$element.hasClass('fade')?
this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
removeBackdrop.call(this)

} else if (callback) {
callback()
}
}

function removeBackdrop() {
this.$backdrop.remove()
this.$backdrop = null
}

function escape() {
var that = this
if (this.isShown && this.options.keyboard) {
$(document).on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide()
})
} else if (!this.isShown) {
$(document).off('keyup.dismiss.modal')
}
}


/* MODAL PLUGIN DEFINITION
* ======================= */

$.fn.modal = function ( option ) {
return this.each(function () {
var $this = $(this)
, data = $this.data('modal')
, options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
if (!data) $this.data('modal', (data = new Modal(this, options)))
if (typeof option == 'string') data[option]()
else if (options.show) data.show()
})
}

$.fn.modal.defaults = {
backdrop: true
, keyboard: true
, show: true
}

$.fn.modal.Constructor = Modal


/* MODAL DATA-API
* ============== */

$(function () {
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
var $this = $(this), href
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
, option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())

e.preventDefault()
$target.modal(option)
})
})

}( window.jQuery );
4 changes: 3 additions & 1 deletion elections/static/other.css
Expand Up @@ -16,14 +16,16 @@ body {

.thumbnail img{
height:163px;
display: block;
margin-left: auto;
margin-right: auto;
}
.dateformat span{
text-align:right;
}
.ranking{
text-align: right;
}

/* RATING
.rating {
float:left;
Expand Down
16 changes: 11 additions & 5 deletions elections/templates/index.html
Expand Up @@ -12,6 +12,12 @@ <h1>Elecciones #HermandadRobot</h1>
</header>
<div class="row">
{# Parte superior #}
{% if not user.is_authenticated %}
<div id="vote_well"class="alert alert-block alert-info fade in">
<a class="close" data-dismiss="alert" href="#">×</a>
<h4 class="alert-heading">Presenta tu candidatura. Date a conocer, regístrate y publica tu candidatura para liderar la #HermandadRobot</h4>
</div>
{% endif %}
{% if registered %}
<div id="vote_well"class="alert alert-block alert-info fade in">
<a class="close" data-dismiss="alert" href="#">×</a>
Expand All @@ -37,15 +43,15 @@ <h4 class="alert-heading">Has votado correctamente</h4>
<!-- Carousel items -->
<div class="carousel-inner">
<div class="item active">
<img src="{{ STATIC_URL }}c1.jpg">
<img src="{{ STATIC_URL }}collage_outsiders.jpg">
<div class="carousel-caption">
<h4>Puaj, para ti</h4>
<p>Come queso, y come limonada. Venga rápido que va a explotar</p>
</div>
</div>

<div class="item">
<img src="{{ STATIC_URL }}c2.jpg">
<img src="{{ STATIC_URL }}collage_samuelers2.jpg">
<div class="carousel-caption">
<h4>Puaj, para ti</h4>
<p>Come queso, y come limonada. Venga rápido que va a explotar</p>
Expand All @@ -71,8 +77,8 @@ <h2>LOREM IPSUM JODER</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque tempus, risus ac vehicula fermentum, magna orci feugiat libero, vel fermentum dui quam venenatis dui. Nulla facilisi. Suspendisse potenti. Cras ac nulla massa, sit amet lacinia lacus. Nunc pellentesque augue sed elit hendrerit imperdiet ornare risus imperdiet. Vivamus eu quam eget orci suscipit volutpat. Duis ultrices, tellus sed euismod dapibus, orci lectus vestibulum enim, in porta massa erat a magna.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque tempus, risus ac vehicula fermentum, magna orci feugiat libero, vel fermentum dui quam venenatis dui. Nulla facilisi. Suspendisse potenti. Cras ac nulla massa, sit amet lacinia lacus.</p>
<div id="social">
<a rel="nofollow" target="_blank" href="http://www.facebook.com/sharer.php?u={{ full_path }}"><img src="{{ STATIC_URL}}facebook.png" alt="fb_share_icon"></a>
<a rel="nofollow" target="_blank" href="https://twitter.com/intent/tweet?url={{ full_path }}&amp;text=Vota%20a%20tu%20favorito%20para%20líder%20de%20la%20HR&amp;hashtags=HRElections"><img src="{{ STATIC_URL }}twitter.png" alt="twitter_icon"></a>
<a rel="nofollow" target="_blank" href="http://www.facebook.com/sharer.php?u=http://vitiman.webfactional.com/"><img src="{{ STATIC_URL}}facebook.png" alt="fb_share_icon"></a>
<a rel="nofollow" target="_blank" href="https://twitter.com/intent/tweet?url=http://vitiman.webfactional.com/&amp;text=Vota%20a%20tu%20favorito%20para%20líder%20de%20la%20HR&amp;hashtags=HRElections"><img src="{{ STATIC_URL }}twitter.png" alt="twitter_icon"></a>
<div class="g-plusone"></div>
</div>
</div>
Expand All @@ -90,7 +96,7 @@ <h2>LOREM IPSUM JODER</h2>
<div class="thumbnail">
{# Thumbnail, titulo, estrellas y texto #}
{# Imagen #}
<img src="{{ candidate.image }}">
<a href="{% url candidate candidate.id %}"><img src="{{ candidate.image }}"></a>
<div class="caption">
{% if already_voted == candidate.id %}
<span class="label label-important">Ya has votado.</span>
Expand Down
2 changes: 1 addition & 1 deletion elections/templates/login.html
Expand Up @@ -44,7 +44,7 @@ <h1>Acceso Candidatos</h1>
</form>
</div>
<div class="span4">
{# Text stuff #}
<p>Accede con tu usuario para publicar y editar tu candidatura para líder de la #HermandadRobot.</p>
</div>
</div>
{% endblock %}
Expand Down
27 changes: 26 additions & 1 deletion elections/templates/publish.html
Expand Up @@ -16,6 +16,11 @@ <h1>Publicar candidatura <small>Preséntate al electorado</small></h1>
Tu candidatura ha sido publicada/editada.
</div>
{% endif %}
{% if deleted %}
<div class="alert alert-success">
Tu candidatura ha sido eliminada.
</div>
{% endif %}

<div class="row">
<div class="span8">
Expand Down Expand Up @@ -78,13 +83,33 @@ <h1>Publicar candidatura <small>Preséntate al electorado</small></h1>
{{ form.editing }}
<div class="form-actions">
<button type="submit" class="btn btn-primary">Enviar</button>
<button type="submit" class="btn btn-danger">Borrar candidatura</button>
<a class="btn btn-danger" data-toggle="modal" href="#myModal" >Borrar candidatura</a>
</div>
</fieldset>
</form>

<div class="modal hide fade" id="myModal">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Borrar candidatura</h3>
</div>
<div class="modal-body">
<p>¿Estás totalmente seguro?</p>
</div>
<div class="modal-footer">
<a href="/publish/?d=y" class="btn btn-primary">Sí, joder</a>
<a href="#" data-dismiss="modal" class="btn">Tengo miedo</a>
</div>
</div>

</div>
<div class="span4">
{# Texto de ayuda #}
</div>
</div>
{% endblock %}
{% block javascript %}
<script src="{{ STATIC_URL }}js/jquery.js"></script>
<script src="{{ STATIC_URL }}js/bootstrap-transition.js"></script>
<script src="{{ STATIC_URL }}js/bootstrap-modal.js"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion elections/templates/register.html
Expand Up @@ -51,7 +51,7 @@ <h1>Registro Candidatos</h1>
</form>
</div>
<div class="span4">
{# Text stuff #}
<p>Para presentar tu candidatura a los ciudadanos regístrate aquí.</p>
</div>
</div>
{% endblock %}
11 changes: 10 additions & 1 deletion elections/views.py
Expand Up @@ -22,7 +22,6 @@ def index(request):
registered = True
else:
registered = False
print registered
if id!=0 and stars!=0:
try:
if int(stars) not in range(1,6):
Expand Down Expand Up @@ -111,6 +110,15 @@ def publish(request):
# Ver si está vacío
published=False
new = False
deleted = False
delete = request.GET.get('d', 'n')
if delete == 'y':
try:
candidate=Candidate.objects.get(user=User.objects.get(username__exact=request.user))
candidate.delete()
deleted = True
except Candidate.DoesNotExist:
pass
if request.method == 'POST':
form = CandidateForm(request.POST)
if form.is_valid():
Expand Down Expand Up @@ -157,6 +165,7 @@ def publish(request):
'form': form,
'published': published,
'new' : new,
'deleted': deleted,
}, context_instance=RequestContext(request))

@login_required(login_url='/login/')
Expand Down

0 comments on commit bf54f7c

Please sign in to comment.