Conjunto fecfc90 en gestor_consulta


Ignorar:
Fecha y hora:
24/08/2017 15:27:39 (hace 7 años)
Autor:
rudmanmrrod <rudman22@…>
Branches:
master
Children:
9b33f35
Parents:
abd93af
Mensaje:

Agregados cambios varios para poner funcional el la creación y borrado de opciones

Ficheros:
5 editados

Leyenda

No modificado
Añadido
Eliminado
  • consulta/rest.py

    rabd93af rfecfc90  
    1616from .models import Consulta, Pregunta
    1717from rest_framework import viewsets
     18from rest_framework.permissions import IsAuthenticated
    1819
    1920
     
    2930    serializer_class = ConsultaSerializer
    3031    http_method_names = ['get','head']
     32    permission_classes = (IsAuthenticated,)
    3133
    3234    def get_queryset(self):
  • gestor_consulta/settings.py

    r2353277 rfecfc90  
    158158EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
    159159
     160## Configuraciones del rest framework
    160161REST_FRAMEWORK = {
    161     'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',),
     162    'DEFAULT_FILTER_BACKENDS': (
     163        'django_filters.rest_framework.DjangoFilterBackend',
     164    ),
     165    'DEFAULT_PERMISSION_CLASSES': (
     166        'rest_framework.permissions.IsAuthenticated',
     167    ),
     168    'DEFAULT_AUTHENTICATION_CLASSES': (
     169        'rest_framework.authentication.SessionAuthentication',
     170        'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
     171    ),
    162172}
  • gestor_consulta/urls.py

    rd7b19bc rfecfc90  
    1717from django.contrib import admin
    1818from rest.routers import router
     19from rest_framework_jwt.views import obtain_jwt_token
     20from rest_framework_jwt.views import refresh_jwt_token
    1921
    2022urlpatterns = [
     
    2527    url(r'^captcha/', include('captcha.urls')),
    2628    url(r'^api/', include('rest_framework.urls', namespace='rest_framework')),
    27     url(r'^api/', include(router.urls))
     29    url(r'^api/', include(router.urls)),
     30    url(r'^api-token-auth/', obtain_jwt_token),
     31    url(r'^api-token-refresh/', refresh_jwt_token),
    2832]
  • static/js/funciones.js

    re4911cf rfecfc90  
    175175                    text:"Guardar",
    176176                    callback:function(){
    177                         submitOption(this);
     177                        submitOption($('.material-dialog #formulario_modal').last());
    178178                    }
    179179                }
     
    190190**/
    191191function submitOption(objecto) {
    192     var input = $(objecto).parent().parent().find('#opciones #id_texto_opcion');
     192    var input = $(objecto).find('#opciones #id_texto_opcion');
    193193    var vacio = false;
    194194    $.each(input,function(key,value){
     
    198198    });
    199199    if (!vacio) {
    200         var form = $(objecto).parent().parent().find('form');
    201200        $.ajax({
    202             data: $(form).serialize(),
     201            data: $(objecto).serialize(),
    203202            type: 'POST',
    204             url: URL_CREAR_OPCIONES+$(form).attr('action'),
     203            url: URL_CREAR_OPCIONES+$(objecto).attr('action'),
    205204            success: function(response) {
    206205                if (response.code) {
     
    308307 * @param id Recibe el id de la pregunta
    309308**/
    310 function del_option(id) {
     309function del_option(objeto,id) {
    311310    MaterialDialog.dialog(
    312311        "¿Desea borrar la opción seleccionada?",
     
    322321                    text:"Si",
    323322                    callback:function(){
    324                         delete_option(id);
     323                        delete_option(objeto,id);
    325324                    }
    326325                }
     
    482481 * @param id Recibe el id de la opcion
    483482**/
    484 function delete_option(id) {
     483function delete_option(objeto,id) {
    485484    var token = $('input').val();
    486485    var input = '';
    487     $.each($('#option_form').find('input'),function(index,value){
     486    $.each($(objeto).find('#option_form input'),function(index,value){
    488487        if ($(value).attr('name') == 'texto_opcion_id' && $(value).val() == id) {
    489488            input = value;
     
    496495        success: function(response) {
    497496            if (response.success) {
    498                 $(input).parent().parent().parent().parent().remove();
     497                $(objeto).parent().parent().remove();
    499498                Materialize.toast("Se eliminó la opción con éxito", 4000);
    500499            }
Nota: Vea TracChangeset para ayuda en el uso del visor de conjuntos de cambios.