Example #1
0
def schedule(request):
    artist = request.user.artist
    _work_time = WorkTime.objects.get(artist=artist)
    work_time = {}
    work_time["mon_start"] = " " if _work_time.mon_start == -1 else HOURS[_work_time.mon_start]
    work_time["mon_end"] = " " if _work_time.mon_end == -1 else HOURS[_work_time.mon_end]
    work_time["tues_start"] = " " if _work_time.tues_start == -1 else HOURS[_work_time.tues_start]
    work_time["tues_end"] = " " if _work_time.tues_end == -1 else HOURS[_work_time.tues_end]
    work_time["wed_start"] = " " if _work_time.wed_start == -1 else HOURS[_work_time.wed_start]
    work_time["wed_end"] = " " if _work_time.wed_end == -1 else HOURS[_work_time.wed_end]
    work_time["thurs_start"] = " " if _work_time.thurs_start == -1 else HOURS[_work_time.thurs_start]
    work_time["thurs_end"] = " " if _work_time.thurs_end == -1 else HOURS[_work_time.thurs_end]
    work_time["fri_start"] = " " if _work_time.fri_start == -1 else HOURS[_work_time.fri_start]
    work_time["fri_end"] = " " if _work_time.fri_end == -1 else HOURS[_work_time.fri_end]
    work_time["sat_start"] = " " if _work_time.sat_start == -1 else HOURS[_work_time.sat_start]
    work_time["sat_end"] = " " if _work_time.sat_end == -1 else HOURS[_work_time.sat_end]
    work_time["sun_start"] = " " if _work_time.sun_start == -1 else HOURS[_work_time.sun_start]
    work_time["sun_end"] = " " if _work_time.sun_end == -1 else HOURS[_work_time.sun_end]
    if request.method == "POST":
        data = request.POST
        _work_time.mon_start = -1 if data["1"] == "-1" else HOURS.index(data["1"])
        _work_time.mon_end = -1 if data["2"] == "-1" else HOURS.index(data["2"])
        _work_time.tues_start = -1 if data["3"] == "-1" else HOURS.index(data["3"])
        _work_time.tues_end = -1 if data["4"] == "-1" else HOURS.index(data["4"])
        _work_time.wed_start = -1 if data["5"] == "-1" else HOURS.index(data["5"])
        _work_time.wed_end = -1 if data["6"] == "-1" else HOURS.index(data["6"])
        _work_time.thurs_start = -1 if data["7"] == "-1" else HOURS.index(data["7"])
        _work_time.thurs_end = -1 if data["8"] == "-1" else HOURS.index(data["8"])
        _work_time.fri_start = -1 if data["9"] == "-1" else HOURS.index(data["9"])
        _work_time.fri_end = -1 if data["10"] == "-1" else HOURS.index(data["10"])
        _work_time.sat_start = -1 if data["11"] == "-1" else HOURS.index(data["11"])
        _work_time.sat_end = -1 if data["12"] == "-1" else HOURS.index(data["12"])
        _work_time.sun_start = -1 if data["13"] == "-1" else HOURS.index(data["13"])
        _work_time.sun_end = -1 if data["14"] == "-1" else HOURS.index(data["14"])
        _work_time.save()
    return render(request, 'artists/settings/schedule.html', { "work_time": work_time })
Example #2
0
def schedule(request, artist_id=None):
    artist = get_object_or_404(Artist, id=int(artist_id))
    _work_time = WorkTime.objects.get(artist=artist)
    work_time = {}
    work_time["mon_start"] = " " if _work_time.mon_start == -1 else HOURS[_work_time.mon_start]
    work_time["mon_end"] = " " if _work_time.mon_end == -1 else HOURS[_work_time.mon_end]
    work_time["tues_start"] = " " if _work_time.tues_start == -1 else HOURS[_work_time.tues_start]
    work_time["tues_end"] = " " if _work_time.tues_end == -1 else HOURS[_work_time.tues_end]
    work_time["wed_start"] = " " if _work_time.wed_start == -1 else HOURS[_work_time.wed_start]
    work_time["wed_end"] = " " if _work_time.wed_end == -1 else HOURS[_work_time.wed_end]
    work_time["thurs_start"] = " " if _work_time.thurs_start == -1 else HOURS[_work_time.thurs_start]
    work_time["thurs_end"] = " " if _work_time.thurs_end == -1 else HOURS[_work_time.thurs_end]
    work_time["fri_start"] = " " if _work_time.fri_start == -1 else HOURS[_work_time.fri_start]
    work_time["fri_end"] = " " if _work_time.fri_end == -1 else HOURS[_work_time.fri_end]
    work_time["sat_start"] = " " if _work_time.sat_start == -1 else HOURS[_work_time.sat_start]
    work_time["sat_end"] = " " if _work_time.sat_end == -1 else HOURS[_work_time.sat_end]
    work_time["sun_start"] = " " if _work_time.sun_start == -1 else HOURS[_work_time.sun_start]
    work_time["sun_end"] = " " if _work_time.sun_end == -1 else HOURS[_work_time.sun_end]
    if request.method == "POST":
        data = request.POST
        _work_time.mon_start = -1 if data["1"] == "-1" else HOURS.index(data["1"])
        _work_time.mon_end = -1 if data["2"] == "-1" else HOURS.index(data["2"])
        _work_time.tues_start = -1 if data["3"] == "-1" else HOURS.index(data["3"])
        _work_time.tues_end = -1 if data["4"] == "-1" else HOURS.index(data["4"])
        _work_time.wed_start = -1 if data["5"] == "-1" else HOURS.index(data["5"])
        _work_time.wed_end = -1 if data["6"] == "-1" else HOURS.index(data["6"])
        _work_time.thurs_start = -1 if data["7"] == "-1" else HOURS.index(data["7"])
        _work_time.thurs_end = -1 if data["8"] == "-1" else HOURS.index(data["8"])
        _work_time.fri_start = -1 if data["9"] == "-1" else HOURS.index(data["9"])
        _work_time.fri_end = -1 if data["10"] == "-1" else HOURS.index(data["10"])
        _work_time.sat_start = -1 if data["11"] == "-1" else HOURS.index(data["11"])
        _work_time.sat_end = -1 if data["12"] == "-1" else HOURS.index(data["12"])
        _work_time.sun_start = -1 if data["13"] == "-1" else HOURS.index(data["13"])
        _work_time.sun_end = -1 if data["14"] == "-1" else HOURS.index(data["14"])
        _work_time.save()

    return render(request, "salons/artist_settings/schedule.html", {"work_time": work_time, "artist": artist})
Example #3
0
def salon_schedule(request, artist_id=None):
    if artist_id == "None":
        salon = request.user.salon
        try:
            artist = Artist.objects.filter(salon=salon, is_activated=True)[0]
            return HttpResponseRedirect(reverse("salons_schedule", kwargs={"artist_id": artist.id}))
        except:
            messages.add_message(request, messages.INFO, "You cannot view the calendar, without have any artists.")
            return HttpResponseRedirect(reverse("salons_artists"))

    salon = request.user.salon
    artist_id = int(artist_id)
    artist = get_object_or_404(Artist, id=artist_id, salon=salon)

    _work_time = WorkTime.objects.get(artist=artist)
    work_time = {}
    work_time["mon_start"] = " " if _work_time.mon_start == -1 else HOURS[_work_time.mon_start]
    work_time["mon_end"] = " " if _work_time.mon_end == -1 else HOURS[_work_time.mon_end]
    work_time["tues_start"] = " " if _work_time.tues_start == -1 else HOURS[_work_time.tues_start]
    work_time["tues_end"] = " " if _work_time.tues_end == -1 else HOURS[_work_time.tues_end]
    work_time["wed_start"] = " " if _work_time.wed_start == -1 else HOURS[_work_time.wed_start]
    work_time["wed_end"] = " " if _work_time.wed_end == -1 else HOURS[_work_time.wed_end]
    work_time["thurs_start"] = " " if _work_time.thurs_start == -1 else HOURS[_work_time.thurs_start]
    work_time["thurs_end"] = " " if _work_time.thurs_end == -1 else HOURS[_work_time.thurs_end]
    work_time["fri_start"] = " " if _work_time.fri_start == -1 else HOURS[_work_time.fri_start]
    work_time["fri_end"] = " " if _work_time.fri_end == -1 else HOURS[_work_time.fri_end]
    work_time["sat_start"] = " " if _work_time.sat_start == -1 else HOURS[_work_time.sat_start]
    work_time["sat_end"] = " " if _work_time.sat_end == -1 else HOURS[_work_time.sat_end]
    work_time["sun_start"] = " " if _work_time.sun_start == -1 else HOURS[_work_time.sun_start]
    work_time["sun_end"] = " " if _work_time.sun_end == -1 else HOURS[_work_time.sun_end]
    if request.method == "POST":
        data = request.POST
        _work_time.mon_start = -1 if data["1"] == "-1" else HOURS.index(data["1"])
        _work_time.mon_end = -1 if data["2"] == "-1" else HOURS.index(data["2"])
        _work_time.tues_start = -1 if data["3"] == "-1" else HOURS.index(data["3"])
        _work_time.tues_end = -1 if data["4"] == "-1" else HOURS.index(data["4"])
        _work_time.wed_start = -1 if data["5"] == "-1" else HOURS.index(data["5"])
        _work_time.wed_end = -1 if data["6"] == "-1" else HOURS.index(data["6"])
        _work_time.thurs_start = -1 if data["7"] == "-1" else HOURS.index(data["7"])
        _work_time.thurs_end = -1 if data["8"] == "-1" else HOURS.index(data["8"])
        _work_time.fri_start = -1 if data["9"] == "-1" else HOURS.index(data["9"])
        _work_time.fri_end = -1 if data["10"] == "-1" else HOURS.index(data["10"])
        _work_time.sat_start = -1 if data["11"] == "-1" else HOURS.index(data["11"])
        _work_time.sat_end = -1 if data["12"] == "-1" else HOURS.index(data["12"])
        _work_time.sun_start = -1 if data["13"] == "-1" else HOURS.index(data["13"])
        _work_time.sun_end = -1 if data["14"] == "-1" else HOURS.index(data["14"])
        _work_time.save()

    artists = Artist.objects.filter(salon=salon, is_activated=True)
    artists = [a.id for a in artists]

    current_index = artists.index(artist_id)
    next = artists[0] if current_index + 1 == len(artists) else artists[current_index + 1]
    prev = artists[-1] if current_index == 0 else artists[current_index - 1]

    return render(
        request,
        "salons/management/schedule.html",
        {"work_time": work_time, "artist": artist, "next": next, "prev": prev},
    )
Example #4
0
def salon_schedule(request, artist_id=None):
    if artist_id == "None":
        salon = request.user.salon
        try:
            artist = Artist.objects.filter(salon=salon, is_activated=True)[0]
            return HttpResponseRedirect(
                reverse('salons_schedule', kwargs={'artist_id': artist.id}))
        except:
            messages.add_message(
                request, messages.INFO,
                'You cannot view the calendar, without have any artists.')
            return HttpResponseRedirect(reverse('salons_artists'))

    salon = request.user.salon
    artist_id = int(artist_id)
    artist = get_object_or_404(Artist, id=artist_id, salon=salon)

    _work_time = WorkTime.objects.get(artist=artist)
    work_time = {}
    work_time["mon_start"] = " " if _work_time.mon_start == -1 else HOURS[
        _work_time.mon_start]
    work_time["mon_end"] = " " if _work_time.mon_end == -1 else HOURS[
        _work_time.mon_end]
    work_time["tues_start"] = " " if _work_time.tues_start == -1 else HOURS[
        _work_time.tues_start]
    work_time["tues_end"] = " " if _work_time.tues_end == -1 else HOURS[
        _work_time.tues_end]
    work_time["wed_start"] = " " if _work_time.wed_start == -1 else HOURS[
        _work_time.wed_start]
    work_time["wed_end"] = " " if _work_time.wed_end == -1 else HOURS[
        _work_time.wed_end]
    work_time["thurs_start"] = " " if _work_time.thurs_start == -1 else HOURS[
        _work_time.thurs_start]
    work_time["thurs_end"] = " " if _work_time.thurs_end == -1 else HOURS[
        _work_time.thurs_end]
    work_time["fri_start"] = " " if _work_time.fri_start == -1 else HOURS[
        _work_time.fri_start]
    work_time["fri_end"] = " " if _work_time.fri_end == -1 else HOURS[
        _work_time.fri_end]
    work_time["sat_start"] = " " if _work_time.sat_start == -1 else HOURS[
        _work_time.sat_start]
    work_time["sat_end"] = " " if _work_time.sat_end == -1 else HOURS[
        _work_time.sat_end]
    work_time["sun_start"] = " " if _work_time.sun_start == -1 else HOURS[
        _work_time.sun_start]
    work_time["sun_end"] = " " if _work_time.sun_end == -1 else HOURS[
        _work_time.sun_end]
    if request.method == "POST":
        data = request.POST
        _work_time.mon_start = -1 if data["1"] == "-1" else HOURS.index(
            data["1"])
        _work_time.mon_end = -1 if data["2"] == "-1" else HOURS.index(
            data["2"])
        _work_time.tues_start = -1 if data["3"] == "-1" else HOURS.index(
            data["3"])
        _work_time.tues_end = -1 if data["4"] == "-1" else HOURS.index(
            data["4"])
        _work_time.wed_start = -1 if data["5"] == "-1" else HOURS.index(
            data["5"])
        _work_time.wed_end = -1 if data["6"] == "-1" else HOURS.index(
            data["6"])
        _work_time.thurs_start = -1 if data["7"] == "-1" else HOURS.index(
            data["7"])
        _work_time.thurs_end = -1 if data["8"] == "-1" else HOURS.index(
            data["8"])
        _work_time.fri_start = -1 if data["9"] == "-1" else HOURS.index(
            data["9"])
        _work_time.fri_end = -1 if data["10"] == "-1" else HOURS.index(
            data["10"])
        _work_time.sat_start = -1 if data["11"] == "-1" else HOURS.index(
            data["11"])
        _work_time.sat_end = -1 if data["12"] == "-1" else HOURS.index(
            data["12"])
        _work_time.sun_start = -1 if data["13"] == "-1" else HOURS.index(
            data["13"])
        _work_time.sun_end = -1 if data["14"] == "-1" else HOURS.index(
            data["14"])
        _work_time.save()

    artists = Artist.objects.filter(salon=salon, is_activated=True)
    artists = [a.id for a in artists]

    current_index = artists.index(artist_id)
    next = artists[0] if current_index + 1 == len(artists) else artists[
        current_index + 1]
    prev = artists[-1] if current_index == 0 else artists[current_index - 1]

    return render(request, 'salons/management/schedule.html', {
        "work_time": work_time,
        "artist": artist,
        "next": next,
        "prev": prev
    })