Пример #1
0
def page_estimated_dope(request, load_pk='3'):
    step_hit_count_by_page(request.path)
    try:
        selected_load = EstimatedDope.objects.get(hand_load=load_pk)
        context = {
            # "restart": get_restart_notice,
            'load_id': load_pk,
            'release': get_version_json(),
            "title": "Estimated Dope",
            # "blurb": "I'll move it to a database setup in a bit.",
            "blurb": get_page_blurb_override('load_data/estimated_dope/'),
            'load_details': selected_load,
            "copy_year": datetime.now().year,
        }
    except ObjectDoesNotExist:
        context = {
            # "restart": get_restart_notice,
            'load_id':
            load_pk,
            'release':
            get_version_json(),
            "title":
            "Master Po Load Data",
            "blurb":
            get_page_blurb_override('load_data/estimated_dope/NO-DOPE-FOUND/'),
            "copy_year":
            datetime.now().year,
        }

    return render(request, "loaddata/estimated_dope.html", context)
Пример #2
0
def page_caliber_detail(request, caliber_pk=None):
    print("caliber details...")
    step_hit_count_by_page(request.path)
    if caliber_pk is None:
        context = {
            'caliber_pk': caliber_pk,
            'release': get_version_json(),
            "title": "Caliber Details",
            "blurb": get_page_blurb_override('load_data/caliber_details/None'),
            "copy_year": datetime.now().year,
        }
        return render(request, "loaddata/caliber_details.html", context)
    try:
        all_loads = HandLoad.objects.filter(
            Q(firearm__caliber__pk=caliber_pk)).order_by(
                'Is_Sheriff_Load', '-prod', '-projectile__Diameter').annotate(
                    prod=ExpressionWrapper(F('projectile__WeightGR') * 0.5 /
                                           7000 / 32.127 * F('Velocity') *
                                           F('Velocity'),
                                           output_field=FloatField()),
                    rps=ExpressionWrapper(F('Velocity') * 720 /
                                          F('firearm__inches_per_twist') / 60,
                                          output_field=IntegerField()))

        # there's probably a better way to do this but, this works for now.
        for load in all_loads:
            load.has_info = False
            has_dope = EstimatedDope.objects.all().filter(Q(hand_load=load.pk))
            if has_dope:
                load.has_info = True

        context = {
            # "restart": get_restart_notice,
            'release': get_version_json(),
            "title": "Load Data",
            "blurb": get_page_blurb_override('load_data/loads/'),
            'all_loads': all_loads,
            "copy_year": datetime.now().year
        }
        return render(request, "loaddata/djangoad.html", context)

    except ObjectDoesNotExist:
        context = {
            'caliber_pk': caliber_pk,
            'release': get_version_json(),
            "title": "Caliber Details",
            "blurb": get_page_blurb_override('load_data/caliber_details/None'),
            "copy_year": datetime.now().year,
        }

    return render(request, "loaddata/caliber_details.html", context)
Пример #3
0
def page_view_watches_reset(request):
    step_hit_count_by_page(request.path)
    users_in_group = Group.objects.get(name="restricted-group").user_set.all()
    if request.user not in users_in_group:
        context = {
            # "restart": get_restart_notice,
            'release': get_version_json(),
            "title": "Status Watcher",
            "blurb":
            "You're not allowed access to this resource at this time.",
            "copy_year": datetime.now().year
        }
        return render(request, "imrunicorn/access_denied.html", context)

    watches = get_watch_list()

    for item in watches:
        # page_search = search_url_for_magic_string(item.item_link, item.item_phrase)
        item.item_exception = "reset"
        item.item_phrase_not_exist = None
        item.save()

    context = {
        # "restart": get_restart_notice,
        'release': get_version_json(),
        "title": "Status Watcher",
        # "blurb": "This page is a place holder for what's to come soon.",
        "blurb": get_page_blurb_override('status_watcher/view_watches/'),
        'watch_list': watches,
        "copy_year": datetime.now().year
    }
    return render(request, "status_watcher/view_list.html", context)
Пример #4
0
def buzz_words_or_phrases_list_all(request):
    step_hit_count_by_page(request.path)
    words = get_all_buzz_words_or_phrases()

    new_entries = words['new_entries']

    word_list = words['result']
    context = {
        "copy_year":
        datetime.now().year,
        'release':
        get_version_json(),
        "title":
        "Content Collection: Buzz Words (or Phrases)",
        "words":
        word_list,
        "new_words_or_phrases":
        new_entries,
        "blurb":
        get_page_blurb_override(
            'content_collection/buzz_words_or_phrases_list_all/'),
    }
    return render(request,
                  "content_collection/buzz_words_or_phrases_list_all.html",
                  context)
Пример #5
0
def page_sketch_by_pk(request, sketch_pk=1):
    step_hit_count_by_page(request.path)
    sketch = get_sketch_by_pk(sketch_pk)

    blurb = get_page_blurb_override(
        'content_collection/sketches/')  # default blurb override
    unrestricted = False
    has_permission = False
    special_permission = 'Content_Collection.View_ArduinoUnoSketch'
    has_permission = request.user.has_perm(special_permission.lower())

    if sketch[0].restricted:
        if has_permission:
            unrestricted = True
            blurb = sketch[0].title
        else:
            blurb = "Sketch title hidden due to access reasons."
    else:
        unrestricted = True
        blurb = sketch[0].title

    context = {
        "sketch": sketch,
        "special_permission": special_permission,
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        'unrestricted_user': unrestricted,
        "title": "Sketch: #{sketch_pk}".format(sketch_pk=sketch_pk),
        "blurb": blurb,
    }
    return render(request, "content_collection/sketch.html", context)
Пример #6
0
def page_days_since(request):
    step_hit_count_by_page(request.path)
    input_date = request.GET.get('input_date')

    blurb_string = "/days_since?input_date=" + input_date

    batf_data = fetch_estimated_batf_days()
    check_cashed = batf_data['check_cashed']
    approved = batf_data['approved']
    stamp_received = batf_data['stamp_received']
    total = batf_data['total']
    cached_result = batf_data['cached_result']

    context = {
        # "restart": get_restart_notice,
        # 'batf_data': total_batf['check_cashed'],
        'cached_result': cached_result,
        'batf_check_cashed': check_cashed,
        'batf_approved': approved,
        'batf_stamp_received': stamp_received,
        'batf_total': total,
        'release': get_version_json(),
        "title": "Days since " + input_date,
        "blurb": get_page_blurb_override(blurb_string),
        "input_date": input_date,
        "copy_year": datetime.now().year
    }
    return render(request, "imrunicorn/days_since.html", context)
Пример #7
0
def admintool_restart_gunicorn_and_nginx(request):
    step_hit_count_by_page(request.path)
    command = ["bash", "admin_toolbox/server_control.sh", "restart_gunicorn_and_nginx"]
    try:
        process = Popen(command, stdout=PIPE, stderr=STDOUT)
        output = process.stdout.read()
        exit_status = process.poll()
        result = {}

        if exit_status == 0:
            result = {"status": "Success", "output": str(output)}
            # return JsonResponse({"status": "Success", "output": str(output)})
        else:
            result = {"status": "Failed", "output": str(output)}
            # return JsonResponse({"status": "Failed", "output": str(output)})
    except Exception as e:
        result = {"status": "failed", "output": str(e)}
        # return JsonResponse({"status": "failed", "output": str(e)})

    context = {
        # "restart": get_restart_notice,
        'release': get_version_json(),
        "title": "AdminTool: Restart Gunicorn & Nginx",
        # "blurb": "I moved the calculator to its own page.",
        "blurb": get_page_blurb_override('admin_tool/restart_gunicorn_and_nginx/'),
        "copy_year": datetime.now().year,
        "table_data": result,
    }
    return render(request, "admin_toolbox/output.html", context)
Пример #8
0
def page_meme_by_subreddit(request, subreddit):
    step_hit_count_by_page(request.path)
    meme = leach_post_subreddit(subreddit)
    print(
        meme
    )  # {'code': 404, 'message': "This subreddit has no posts or doesn't exist."}
    buffer = {}
    try:
        if meme['code'] == 404:
            buffer['subreddit'] = subreddit
            buffer[
                'title'] = "This subreddit has no posts or doesn't exist. Here's a random picsum picture."
            buffer['url'] = "https://picsum.photos/400"
            meme = buffer
    except KeyError as key_error:
        print("We found a key_error, because it has valid data!")

    context = {
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Meme Leach: {0}".format(subreddit),
        "meme": meme,
        "blurb": get_page_blurb_override('meme_leach/fetch'),
    }
    return render(request, "meme_leach/subreddit.html", context)
Пример #9
0
def powder_create_view(request):
    step_hit_count_by_page(request.path)
    # data = {'Query': 'Complete', 'Result': 'The query completed but this is not an endpoint with data.'}
    # return JsonResponse(data)
    form = PowderForm(request.POST or None)
    if form.is_valid():
        # over ride values to track the submission
        safe_form = form.save(commit=False)
        safe_form.author_pk = request.user.pk
        safe_form.is_approved = False
        safe_form.save()

        form = PowderForm()

    all_powders = Powder.objects.all().order_by('-name')

    context = {
        # "restart": get_restart_notice,
        'release': get_version_json(),
        "title": "Powder Creation Tool",
        # "blurb": "I moved the calculator to its own page.",
        "blurb": get_page_blurb_override('load_data/toolbox/create_powder/'),
        "copy_year": datetime.now().year,
        "all_powders": all_powders,
        'form': form,
    }
    return render(request, "loaddata/powder_create.html", context)
Пример #10
0
def page_groundhog_removals_scoreboard_annual(request):
    step_hit_count_by_page(request.path)
    logs = groundhog_removal_scoreboard_annual()
    last_year = datetime.now() - timedelta(days=(1 * 365))
    last_year_year = last_year.strftime("%Y")
    last_year_month = last_year.strftime("%B")
    last_year_day = last_year.strftime("%m")
    rolling_year_date = "{0} {1} of {2}".format(last_year_month,
                                                ordinal(last_year_day),
                                                last_year_year)

    now = datetime.now()
    now_year = now.strftime("%Y")
    now_month = now.strftime("%B")
    now_day = now.strftime("%m")
    now_string = "{0} {1} of {2}".format(now_month, ordinal(now_day), now_year)

    context = {
        # "restart": get_restart_notice,
        "copy_year": datetime.now().year,
        "rolling_year_date": rolling_year_date,
        "datetime_now": now_string,
        "logs": logs,
        'release': get_version_json(),
        "title": "Top Groundhog Removers",
        "blurb":
        get_page_blurb_override('groundhog_logbook/removal_scoreboard/'),
    }
    return render(
        request, "groundhog_logbook/groundhog_removal_scoreboard_annual.html",
        context)
Пример #11
0
def caliber_create_view(request):
    step_hit_count_by_page(request.path)
    form = CaliberForm(request.POST or None)
    if form.is_valid():
        # over ride values to track the submission
        safe_form = form.save(commit=False)
        safe_form.author_pk = request.user.pk
        safe_form.is_approved = False
        safe_form.save()

        form = CaliberForm()

    all_calibers = Caliber.objects.all().order_by('-diameter')

    context = {
        # "restart": get_restart_notice,
        'release': get_version_json(),
        "title": "Caliber Creation Tool",
        # "blurb": "I moved the calculator to its own page.",
        "blurb": get_page_blurb_override('load_data/toolbox/create_caliber/'),
        "copy_year": datetime.now().year,
        "all_calibers": all_calibers,
        'form': form,
    }
    return render(request, "loaddata/caliber_create.html", context)
Пример #12
0
def page_blank(request):
    step_hit_count_by_page(request.path)
    context = {
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Deer Wait List: Blank",
        "blurb": get_page_blurb_override('deer_wait_list/blank/'),
    }
    return render(request, "deer_wait_list/blank.html", context)
Пример #13
0
def page_home(request):
    step_hit_count_by_page(request.path)
    context = {
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Bingo: Home",
        "blurb": get_page_blurb_override('bingo/home/'),
    }
    return render(request, "bingo/home.html", context)
Пример #14
0
def page_home(request):
    step_hit_count_by_page(request.path)
    context = {
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Shooting Challenges",
        "blurb": get_page_blurb_override('shooting_challenge/home/'),
    }
    return render(request, "shooting_challenge/home.html", context)
Пример #15
0
def home_create_view(request):
    step_hit_count_by_page(request.path)
    context = {
        'release': get_version_json(),
        "title": "C.R.U.D. Home",
        "blurb": get_page_blurb_override('load_data/toolbox/create_home/'),
        "copy_year": datetime.now().year,
    }
    return render(request, "loaddata/create_home.html", context)
Пример #16
0
def page_coming_soon(request):
    step_hit_count_by_page(request.path)
    context = {
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "DCSA Info: Coming Soon",
        "blurb": get_page_blurb_override('dcsa_info/coming_soon/'),
    }
    return render(request, "dcsa_info/coming_soon.html", context)
Пример #17
0
def page_blank(request):
    step_hit_count_by_page(request.path)
    context = {
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Activity Log: home",
        "blurb": get_page_blurb_override('activity_log/home/'),
    }
    return render(request, "activity_log/home.html", context)
Пример #18
0
def page_blank(request):
    step_hit_count_by_page(request.path)
    context = {
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Content Collection: Blank",
        "blurb": get_page_blurb_override('content_collection/blank/'),
    }
    return render(request, "content_collection/blank.html", context)
Пример #19
0
def page_loads_by_type(request, load_type='All'):
    step_hit_count_by_page(request.path)
    load_type = load_type.lower()
    if load_type == 'ocw':
        load_type = 'ocw'
        all_loads = HandLoad.objects.all().filter(
            Q(Is_Sheriff_Load=False) | Q(Is_Sheriff_Load=False)).order_by(
                'Is_Sheriff_Load', '-prod', '-projectile__Diameter').annotate(
                    prod=ExpressionWrapper(F('projectile__WeightGR') * 0.5 /
                                           7000 / 32.127 * F('Velocity') *
                                           F('Velocity'),
                                           output_field=FloatField()),
                    rps=ExpressionWrapper(F('Velocity') * 720 /
                                          F('firearm__inches_per_twist') / 60,
                                          output_field=IntegerField()))
    elif load_type == 'sheriff':
        load_type = 'sheriff'
        all_loads = HandLoad.objects.all().filter(
            Q(Is_Sheriff_Load=True) | Q(Is_Sheriff_Load=True)).order_by(
                'Is_Sheriff_Load', '-prod', '-projectile__Diameter').annotate(
                    prod=ExpressionWrapper(F('projectile__WeightGR') * 0.5 /
                                           7000 / 32.127 * F('Velocity') *
                                           F('Velocity'),
                                           output_field=FloatField()),
                    rps=ExpressionWrapper(F('Velocity') * 720 /
                                          F('firearm__inches_per_twist') / 60,
                                          output_field=IntegerField()))
    else:
        load_type = 'all'
        all_loads = HandLoad.objects.all().filter(
            Q(Is_Sheriff_Load=True) | Q(Is_Sheriff_Load=False)).order_by(
                'Is_Sheriff_Load', '-prod', '-projectile__Diameter').annotate(
                    prod=ExpressionWrapper(F('projectile__WeightGR') * 0.5 /
                                           7000 / 32.127 * F('Velocity') *
                                           F('Velocity'),
                                           output_field=FloatField()),
                    rps=ExpressionWrapper(F('Velocity') * 720 /
                                          F('firearm__inches_per_twist') / 60,
                                          output_field=IntegerField()))

    # there's probably a better way to do this but, this works for now.
    for load in all_loads:
        load.has_info = False
        has_dope = EstimatedDope.objects.all().filter(Q(hand_load=load.pk))
        if has_dope:
            load.has_info = True

    context = {
        # "restart": get_restart_notice,
        'release': get_version_json(),
        "title": "Load Data: %s" % load_type,
        "blurb": get_page_blurb_override('load_data/loads/'),
        'all_loads': all_loads,
        "copy_year": datetime.now().year
    }
    return render(request, "loaddata/djangoad.html", context)
Пример #20
0
def page_farm_check_list(request):
    step_hit_count_by_page(request.path)
    context = {
        'release': get_version_json(),
        "title": "What should I bring?",
        # "blurb": "Pre-pack your car/truck it helps to prevent forgetting things.",
        "blurb": get_page_blurb_override('/farm_invite/pending/'),
        "copy_year": datetime.now().year
    }
    return render(request, "farminvite/what_to_bring.html", context)
Пример #21
0
def page_point_system_show_points(request):
    context = {
        "hide_points": False,
        "restart": get_restart_notice,
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Deer Harvest Point System",
        "blurb": get_page_blurb_override('deer_harvest_logbook/point_system/'),
    }
    return render(request, "deer_harvest_logbook/point_system.html", context)
Пример #22
0
def page_all_harvests(request):
    context = {
        "restart": get_restart_notice,
        "copy_year": datetime.now().year,
        "all_news": all_harvests,
        'release': get_version_json(),
        "title": "Deer Harvest Logbook",
        "blurb": get_page_blurb_override('deer_harvest_logbook/'),
    }
    return render(request, "deer_harvest_logbook/all_harvests.html", context)
Пример #23
0
def page_trophy_stats(request):
    step_hit_count_by_page(request.path)
    context = {
        # "restart": get_restart_notice,
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Call Of The Wild: Trophy Stats",
        "blurb": get_page_blurb_override('call_of_the_wild/need_zone_times/'),
    }
    return render(request, "call_of_the_wild/trophy_stats.html", context)
Пример #24
0
def page_blank(request):
    step_hit_count_by_page(request.path)
    context = {
        # "restart": get_restart_notice,
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Call Of The Wild: Blank",
        "blurb": get_page_blurb_override('call_of_the_wild/blank/'),
    }
    return render(request, "call_of_the_wild/blank.html", context)
Пример #25
0
def page_nsfw_meme_list(request):
    step_hit_count_by_page(request.path)
    memes = get_meme_list(request, True)
    context = {
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Meme List",
        "memes": memes,
        "blurb": get_page_blurb_override('meme_leach/'),
    }
    return render(request, "meme_leach/nsfw-list.html", context)
Пример #26
0
def page_meme(request):
    step_hit_count_by_page(request.path)
    meme = leach_post()
    context = {
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Meme Leach",
        "meme": meme,
        "blurb": get_page_blurb_override('meme_leach/fetch'),
    }
    return render(request, "meme_leach/subreddit.html", context)
Пример #27
0
def page_current_points(request):
    step_hit_count_by_page(request.path)
    data = activity_tasks_per_user()
    context = {
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Activity Log: Current Points",
        "blurb": get_page_blurb_override('activity_log/current_points/'),
        "data": data,
    }
    return render(request, "activity_log/tasks_per_user.html", context)
Пример #28
0
def page_momma_pics(request):
    step_hit_count_by_page(request.path)
    momma_stuff = momma_pics("All")
    context = {
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Puppy Fostering: Momma Pics",
        "dataset": momma_stuff,
        "blurb": get_page_blurb_override('puppy_fostering/momma_pics/'),
    }
    return render(request, "puppy_fostering/momma.html", context)
Пример #29
0
def page_puppy_pics(request):
    step_hit_count_by_page(request.path)
    puppy_pics = all_puppy_pics()
    context = {
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Puppy Fostering: Puppy Pics",
        "dataset": puppy_pics,
        "blurb": get_page_blurb_override('puppy_fostering/puppy_pics/'),
    }
    return render(request, "puppy_fostering/puppy.html", context)
Пример #30
0
def page_point_system(request):
    step_hit_count_by_page(request.path)
    context = {
        "hide_points": True,
        # "restart": get_restart_notice,
        "copy_year": datetime.now().year,
        'release': get_version_json(),
        "title": "Deer Harvest Point System",
        "blurb": get_page_blurb_override('deer_harvest_logbook/point_system/'),
    }
    return render(request, "deer_harvest_logbook/point_system.html", context)