Skip to content
Browse files

Subiendo nuevos estáticos y pruebas de envío de email con errores

  • Loading branch information...
1 parent 75c9c0b commit bf54f7cb71f8879a765b80bada29dfc5c25aeab9 Victoriano Navarro Aguilar committed Feb 24, 2012
View
BIN 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.
View
BIN 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.
View
210 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 );
View
4 elections/static/other.css
@@ -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;
View
16 elections/templates/index.html
@@ -12,6 +12,12 @@
</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>
@@ -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>
@@ -71,8 +77,8 @@ <h4 class="alert-heading">Has votado correctamente</h4>
<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>
@@ -90,7 +96,7 @@ <h4 class="alert-heading">Has votado correctamente</h4>
<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>
View
2 elections/templates/login.html
@@ -44,7 +44,7 @@
</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 %}
View
27 elections/templates/publish.html
@@ -16,6 +16,11 @@
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">
@@ -78,13 +83,33 @@
{{ 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 %}
View
2 elections/templates/register.html
@@ -51,7 +51,7 @@
</form>
</div>
<div class="span4">
- {# Text stuff #}
+ <p>Para presentar tu candidatura a los ciudadanos regístrate aquí.</p>
</div>
</div>
{% endblock %}
View
11 elections/views.py
@@ -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):
@@ -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():
@@ -157,6 +165,7 @@ def publish(request):
'form': form,
'published': published,
'new' : new,
+ 'deleted': deleted,
}, context_instance=RequestContext(request))
@login_required(login_url='/login/')
View
13 scripts/set_ranking.py
@@ -6,11 +6,11 @@
import datetime
HOST=u'localhost'
-#USER=u'vitiman_hr_elec'
-#PASS=u'murcia'
-USER=u'admin'
-PASS=u'P0s0t147369'
-DB=u'hr_elections'
+USER=u'vitiman_hr_elec'
+PASS=u'murcia'
+#USER=u'admin'
+#PASS=u'P0s0t147369'
+DB=u'vitiman_hr_elec'
MAX_VOTES_POINTS = 3
MAX_AVG_POINTS = 5
@@ -54,7 +54,8 @@
max_votes = results_avg[0]['votes']
if max_votes >0:
for result in results_avg:
- result['votes_points']=float((result['votes']*MAX_VOTES_POINTS)/max_votes)
+ result['votes_points']=(result['votes']*MAX_VOTES_POINTS)/float(max_votes)
+ print "Votes::{0},MAX_VOTES::{1},max_votes::{2},vote_points::{3}".format(result['votes'],MAX_VOTES_POINTS,max_votes,result['votes_points'])
else:
for result in results_avg:
result['votes_points']=0
View
7 settings.py
@@ -7,6 +7,13 @@
# ('Your Name', 'your_email@example.com'),
)
+EMAIL_HOST = 'smtp.webfaction.com'
+EMAIL_HOST_USER = 'vitiman'
+EMAIL_HOST_PASSWORD = 'murcia'
+DEFAULT_FROM_EMAIL = 'hr_elections@vitiman.webfactional.com'
+SERVER_EMAIL = 'hr_elections@vitiman.webfactional.com'
+
+
MANAGERS = ADMINS
DATABASES = {

0 comments on commit bf54f7c

Please sign in to comment.
Something went wrong with that request. Please try again.