1. 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) RSS

    Добавить комментарий