1. Список говнокодов пользователя eternalfame

    Всего: 5

  2. JavaScript / Говнокод #25302

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    ...
    removed: function(row) {
    
        if ($(row).find('textarea')[0].style.backgroundColor === "red") {
            $(row).find('textarea')[0].style.backgroundColor = "white";
            --disabled_elements_count;
        }
    
        if (disabled_elements_count === 0) {
            $("input[type='submit']").prop('disabled', false);
        }
    }, ...

    eternalfame, 11 Января 2019

    Комментарии (3)
  3. JavaScript / Говнокод #25299

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $( obj ).text( "Сохранение..." );
    
      $.ajax({
        url: url,
        type: "POST",
        data: params,
        dataType: "json",
        success: function( response ) {
          $(obj).parent().parent().parent().parent().parent().html( response.data );
          prepareeventhandlers();
        }
      });

    eternalfame, 10 Января 2019

    Комментарии (2)
  4. Python / Говнокод #19335

    −49

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    class FeedbackForm(forms.Form):
        fullname = forms.CharField(max_length=100, required=True)
        phone = RUPhoneNumberField(required=False)
        email = forms.EmailField(required=True)
        feedback = forms.CharField(widget=forms.Textarea, required=True)
    
    def feedback_and_suggestions(request):
        if request.method == 'POST':
            form = FeedbackForm(request.POST)
            name_ = request.POST.get('fullname')
            email_ = request.POST.get('email')
            phone_ = request.POST.get('phone')
            feedback_ = request.POST.get('feedback')
            error = ''
            if form.is_valid():
                feedback_row = Feedback(name=name_, email=email_, phone=phone_, feedback=feedback_)
                feedback_row.save()
                return HttpResponse('Спасибо!')
            else:
                if name_ == '':
                    error += 'Имя обязательно.'
                else:
                    if 'name' in form._errors:
                        error += 'Имя введено неверно.'
                if 'phone' in form._errors:
                    error += '<br>Неправильный формат телефонного номера.'
                if email_ == '':
                    error += '<br>E-mail обязателен.'
                else:
                    if 'email' in form._errors:
                        error += '<br>E-mail введён неверно.'
                if feedback_ == '':
                    error += '<br>Текст сообщения обязателен.'
                return HttpResponse(error)

    зачем писать валидаторы, кому нужен ModelForm и прочие радости

    eternalfame, 20 Января 2016

    Комментарии (4)
  5. Python / Говнокод #19320

    −50

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    # собственно, сам костыль--------------------------------
    crutch = {
        u'u0401': u'Ё', u'u0451': u'ё',
        u'u0410': u'А', u'u0430': u'а',
        u'u0411': u'Б', u'u0431': u'б',
        u'u0412': u'В', u'u0432': u'в',
        u'u0413': u'Г', u'u0433': u'г',
        u'u0414': u'Д', u'u0434': u'д',
        u'u0415': u'Е', u'u0435': u'е',
        u'u0416': u'Ж', u'u0436': u'ж',
        u'u0417': u'З', u'u0437': u'з',
        u'u0418': u'И', u'u0438': u'и',
        u'u0419': u'Й', u'u0439': u'й',
        u'u041a': u'К', u'u043a': u'к',
        u'u041b': u'Л', u'u043b': u'л',
        u'u041c': u'М', u'u043c': u'м',
        u'u041d': u'Н', u'u043d': u'н',
        u'u041e': u'О', u'u043e': u'о',
        u'u041f': u'П', u'u043f': u'п',
        u'u0420': u'Р', u'u0440': u'р',
        u'u0421': u'С', u'u0441': u'с',
        u'u0422': u'Т', u'u0442': u'т',
        u'u0423': u'У', u'u0443': u'у',
        u'u0424': u'Ф', u'u0444': u'ф',
        u'u0425': u'Х', u'u0445': u'х',
        u'u0426': u'Ц', u'u0446': u'ц',
        u'u0427': u'Ч', u'u0447': u'ч',
        u'u0428': u'Ш', u'u0448': u'ш',
        u'u0429': u'Щ', u'u0449': u'щ',
        u'u042a': u'Ъ', u'u044a': u'ъ',
        u'u042b': u'Ы', u'u044b': u'ы',
        u'u042c': u'Ь', u'u044c': u'ь',
        u'u042d': u'Э', u'u044d': u'э',
        u'u042e': u'Ю', u'u044e': u'ю',
        u'u042f': u'Я', u'u044f': u'я',
    }
    # -------------------------------------------------------
    
        def save(self, *args, **kwargs):
            text = ''
            temp_list = []
            old_list = self.characteristics.split("'")
            del old_list[::2]
            for elem in old_list:
                # temp = (elem.split(':')[0], elem.split(':')[1])
                # БОООЛЬШУУУЩИЙ ТАКОЙ КОСТЫЛИЩЕ-------------------------------------------
                temp_first = elem.split(':')[0]
                temp_second = elem.split(':')[1]
                if temp_first.find(u'\\u') != -1:
                    temp_first_list = temp_first.split('\\')
                    temp_first = u''
                    if temp_first_list[0] == u'':
                        temp_first_list.pop(0)
                    for char in temp_first_list:
                        if char.find(u'u04') == -1:
                            temp_first += char
                        else:
                            if len(char) == 5:
                                temp_first += crutch.get(char)
                            else:
                                temp_first += crutch.get(char[:5])
                                temp_first += char[5:]
                if temp_second.find(u'\\u') != -1:
                    temp_second_list = temp_second.split('\\')
                    temp_second = u''
                    if temp_second_list[0] == u'':
                        temp_second_list.pop(0)
                    for char in temp_second_list:
                        if char.find(u'u04') == -1:
                            temp_second += char
                        else:
                            if len(char) == 5:
                                temp_second += crutch.get(char)
                            else:
                                temp_second += crutch.get(char[:5])
                                temp_second += char[5:]
                temp = (temp_first, temp_second)
                # ------------------------------------------------------------------------
                temp_list.append(temp)
            old = dict(temp_list)
            print(old)
            temp = ItemCharacteristics.objects.filter(sections=self.section)
            for elem in temp:
                # temp_text = old.get(unicode(elem.title))
                temp_text = old.get(elem.title)
                if temp_text is None:
                    temp_text = 'xxx'
                text += unicode(elem) + ':' + temp_text + ';'
            self.characteristics = text
            super(Items, self).save(*args, **kwargs)

    комментарии оригинальные

    eternalfame, 18 Января 2016

    Комментарии (4)
  6. Python / Говнокод #19319

    −46

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    def add_services_to_context(context_dict):
        services = Service.objects.filter(is_active=True)
    
        try:
            serv0 = services.get(service=0).content
        except Service.DoesNotExist:
            serv0 = ''
        except Service.MultipleObjectsReturned:
            serv0 = services.filter(service=0).first().content
    
        try:
            serv1 = services.get(service=1).content
        except Service.DoesNotExist:
            serv1 = ''
        except Service.MultipleObjectsReturned:
            serv1 = services.filter(service=1).first().content
    
        try:
            serv2 = services.get(service=2).content
        except Service.DoesNotExist:
            serv2 = ''
        except Service.MultipleObjectsReturned:
            serv2 = services.filter(service=2).first().content
    
        try:
            serv3 = services.get(service=3).content
        except Service.DoesNotExist:
            serv3 = ''
        except Service.MultipleObjectsReturned:
            serv3 = services.filter(service=3).first().content
    
        try:
            serv4 = services.get(service=4).content
        except Service.DoesNotExist:
            serv4 = ''
        except Service.MultipleObjectsReturned:
            serv4 = services.filter(service=4).first().content
    
        try:
            serv5 = services.get(service=5).content
        except Service.DoesNotExist:
            serv5 = ''
        except Service.MultipleObjectsReturned:
            serv5 = services.filter(service=5).first().content
    
        try:
            serv6 = services.get(service=6).content
        except Service.DoesNotExist:
            serv6 = ''
        except Service.MultipleObjectsReturned:
            serv6 = services.filter(service=6).first().content
    
        try:
            serv7 = services.get(service=7).content
        except Service.DoesNotExist:
            serv7 = ''
        except Service.MultipleObjectsReturned:
            serv7 = services.filter(service=7).first().content
    
        try:
            serv9 = services.get(service=9).content
        except Service.DoesNotExist:
            serv9 = ''
        except Service.MultipleObjectsReturned:
            serv9 = services.filter(service=9).first().content
    
        try:
            serv10 = services.get(service=10).content
        except Service.DoesNotExist:
            serv10 = ''
        except Service.MultipleObjectsReturned:
            serv10 = services.filter(service=10).first().content
    
        try:
            serv11 = services.get(service=11).content
        except Service.DoesNotExist:
            serv11 = ''
        except Service.MultipleObjectsReturned:
            serv11 = services.filter(service=11).first().content
    
        services_dict = {
            '0': serv0,
            '1': serv1,
            '2': serv2,
            '3': serv3,
            '4': serv4,
            '5': serv5,
            '6': serv6,
            '7': serv7,
            '9': serv9,
            '10': serv10,
            '11': serv11,
        }
        context_dict['services'] = services_dict

    Код остался от предыдущего программиста

    eternalfame, 18 Января 2016

    Комментарии (6)