Best Python code snippet using tempest_python
tooltip_html.py
Source:tooltip_html.py
1def html_maker():2 3#416 updated_airbnb_map 4 5 html = """6 <!DOCTYPE html>7 <html lang="en">8 <head>9 <link href="http://fonts.googleapis.com/css?family=Lato:400,700,900" rel="stylesheet" type="text/css">10 <link href="{}/airbnb_app/static/ia_copy_tooltip.css" rel="stylesheet" type="text/css">""".format(BASE_DIR) + """11 </head>12 <div id="listingHover" class="pinned" style="left: 50px; visibility: visible; top: auto; bottom: 2px;">13 <button type="button" class="close" data-dismiss="modal" aria-label="Close" id="closeHover" style="visibility: visible;"><span aria-hidden="true">Ã</span></button>14 <div class="hostDetailsContainer">15 <p><a id="listingHost" target="_blank" href="http://www.airbnb.com/users/show/{}">""".format(host_id) + """{}</a>""".format(host_name) + """ ({}) </p>""".format(host_location) + """ 16 <!-- want to say if have liscenese then show the number if not then say no liscnese illegal etc with django template can use if logic block -->17 <p id="listingHostLicense"><span id="listingHostLicense">Hosting since: {}</span>""".format(host_since) + """</p>18 <p id="listingHostLicense"><span id="listingHostLicense">{}</span>""".format(license) + """ No License </p>19 <p id="listingHostCountContainer">(<span id="listingHostListingCount">{}</span>""".format(host_total_listings_count) + """ other listings locally)</p>20 </div>21 <div class="listingDetailsContainer">22 <p id="listingIDContainer"><a id="listingID" target="_blank" href={}>""".format(listing_url) + """ {}</a>""".format(listing_id) + """</p>23 <p id="listingNameContainer"><a id="listingName" target="_blank" href={}>""".format(listing_url) + """{}</a>""".format(listing_name) + """</p>24 <p id="listingNeighbourhood">{}</p>""".format(neighbourhood_cleansed) + """25 <p id="listingNeighbourhoodDistDuomo">{} meters to the Duomo</p>""".format(dist_duomo) + """26 <p id="listingRoomType">{} ({} bedrooms, accommodates {})</p>""".format(room_type, bedrooms, accommodates) + """27 </div>28 <div id="listingPriceSection" class="listingSection">29 <p class="listingSectionHeadlineContainer">30 <span class="listingSectionHeadline"><span class="dollarSign">â¬</span><span id="listingEstimatedIncomePerYear">{}</span>""".format(rounded_revenue_ltm) + """</span><span id="listingPriceLabel" class="listingSectionHeadlineLabel"> income/year (est.)</span>31 </p>32 <p <span class="listingSectionSubhead"><span class="dollarSign">â¬</span><span id="listingEstimatedIncomePerMonth">{}</span>""".format(monthly_rounded_revenue_ltm) + """</span><span id="listingPriceLabel" class="listingSectionSubhead"> income/month (est.)</span> </p>33 <p class="listingSectionSubhead"><span class="dollarSign">â¬</span><span id="listingPrice">{}</span>""".format(price) + """/night</p>34 </div>35 <div id="listingReviewsSection" class="listingSection">36 <p class="listingSectionHeadlineContainer">37 <span class="listingSectionSubhead"><span id="listingEstimatedNightsPerYear" class="listingSectionHeadline">{}</span>""".format(days_rented_ltm) + """<span class="listingSectionHeadlineLabel"> nights/year (est.)</span></span>38 </p>39 <!-- <p class="listingSectionSubhead"><span id="listingEstimatedOccupancyRate">23.4</span>% occupancy rate (est.)</p> -->40 <p class="listingSectionSubhead"><span id="listingReviewPerMonth">{}</span>""".format(reviews_per_month) + """ reviews/month</p>41 <!-- <p class="listingSectionSubhead"><span id="listingNumberOfReviews">5</span><span id="listingReviewsLabel"> reviews</span></p> -->42 <!-- <p class="listingSectionSubhead">last: <span id="listingLastReview">31/10/2021</span></p> -->43 </div>44 <div id="listingCensusSection" class= "listingSection">45 </div>46 <p class="listingSection">click listing on map to "pin" details</p>47 <p class="listingSection">the style for this popup was created by <a href="http://insideairbnb.com/">Inside Airbnb</a></p>48 </div>49 </html>50 """ 51#278 original_airbnb_map 52html = """53 <!DOCTYPE html>54 <html lang="en">55 <head>56 <link href="http://fonts.googleapis.com/css?family=Lato:400,700,900" rel="stylesheet" type="text/css">57 <link href="{}/airbnb_app/static/ia_copy_tooltip.css" rel="stylesheet" type="text/css">""".format(BASE_DIR) + """58 </head>59 <div id="listingHover" class="pinned" style="left: 50px; visibility: visible; top: auto; bottom: 2px;">60 <button type="button" class="close" data-dismiss="modal" aria-label="Close" id="closeHover" style="visibility: visible;"><span aria-hidden="true">Ã</span></button>61 <div class="hostDetailsContainer">62 <p><a id="listingHost" target="_blank" href="http://www.airbnb.com/users/show/{}">""".format(host_id) + """{}</a>""".format(host_name) + """ ({}) </p>""".format(host_location) + """ 63 <!-- want to say if have liscenese then show the number if not then say no liscnese illegal etc with django template can use if logic block -->64 <p id="listingHostLicense"><span id="listingHostLicense">Hosting since: {}</span>""".format(host_since) + """</p>65 <p id="listingHostLicense"><span id="listingHostLicense">{}</span>""".format(license) + """ No License </p>66 <p id="listingHostCountContainer">(<span id="listingHostListingCount">{}</span>""".format(host_total_listings_count) + """ other listings locally)</p>67 </div>68 <div class="listingDetailsContainer">69 <p id="listingIDContainer"><a id="listingID" target="_blank" href={}>""".format(listing_url) + """ {}</a>""".format(listing_id) + """</p>70 <p id="listingNameContainer"><a id="listingName" target="_blank" href={}>""".format(listing_url) + """{}</a>""".format(listing_name) + """</p>71 <p id="listingNeighbourhood">{}</p>""".format(neighbourhood_cleansed) + """72 <p id="listingNeighbourhoodDistDuomo">{} meters to the Duomo</p>""".format(dist_duomo) + """73 <p id="listingRoomType">{} ({} bedrooms, accommodates {})</p>""".format(room_type, bedrooms, accommodates) + """74 </div>75 <div id="listingPriceSection" class="listingSection">76 <p class="listingSectionHeadlineContainer">77 <span class="listingSectionHeadline"><span class="dollarSign">â¬</span><span id="listingEstimatedIncomePerYear">{}</span>""".format(rounded_revenue_ltm) + """</span><span id="listingPriceLabel" class="listingSectionHeadlineLabel"> income/year (est.)</span>78 </p>79 <p <span class="listingSectionSubhead"><span class="dollarSign">â¬</span><span id="listingEstimatedIncomePerMonth">{}</span>""".format(monthly_rounded_revenue_ltm) + """</span><span id="listingPriceLabel" class="listingSectionSubhead"> income/month (est.)</span> </p>80 <p class="listingSectionSubhead"><span class="dollarSign">â¬</span><span id="listingPrice">{}</span>""".format(price) + """/night</p>81 </div>82 <div id="listingReviewsSection" class="listingSection">83 <p class="listingSectionHeadlineContainer">84 <span class="listingSectionSubhead"><span id="listingEstimatedNightsPerYear" class="listingSectionHeadline">{}</span>""".format(days_rented_ltm) + """<span class="listingSectionHeadlineLabel"> nights/year (est.)</span></span>85 </p>86 <!-- <p class="listingSectionSubhead"><span id="listingEstimatedOccupancyRate">23.4</span>% occupancy rate (est.)</p> -->87 <p class="listingSectionSubhead"><span id="listingReviewPerMonth">{}</span>""".format(reviews_per_month) + """ reviews/month</p>88 <!-- <p class="listingSectionSubhead"><span id="listingNumberOfReviews">5</span><span id="listingReviewsLabel"> reviews</span></p> -->89 <!-- <p class="listingSectionSubhead">last: <span id="listingLastReview">31/10/2021</span></p> -->90 </div>91 <div id="listingCensusSection" class= "listingSection">92 </div>93 <p class="listingSection">click listing on map to "pin" details</p>94 <p class="listingSection">the style for this popup was created by <a href="http://insideairbnb.com/">Inside Airbnb</a></p>95 </div>96 </html>97 """ 98#485 updated_airbnb_map 99html = """100 <!DOCTYPE html>101 <html lang="en">102 <head>103 <link href="http://fonts.googleapis.com/css?family=Lato:400,700,900" rel="stylesheet" type="text/css">104 <link href="{}/airbnb_app/static/ia_copy_tooltip.css" rel="stylesheet" type="text/css">""".format(BASE_DIR) + """105 </head>106 <div id="listingHover" class="pinned" style="left: 50px; visibility: visible; top: auto; bottom: 2px;">107 <button type="button" class="close" data-dismiss="modal" aria-label="Close" id="closeHover" style="visibility: visible;"><span aria-hidden="true">Ã</span></button>108 <div class="hostDetailsContainer">109 <p><a id="listingHost" target="_blank" href="http://www.airbnb.com/users/show/{}">""".format(host_id) + """{}</a>""".format(host_name) + """ ({}) </p>""".format(host_location) + """ 110 <!-- want to say if have liscenese then show the number if not then say no liscnese illegal etc with django template can use if logic block -->111 <p id="listingHostLicense"><span id="listingHostLicense">Hosting since: {}</span>""".format(host_since) + """</p>112 <p id="listingHostLicense"><span id="listingHostLicense">{}</span>""".format(license) + """ No License </p>113 <p id="listingHostCountContainer">(<span id="listingHostListingCount">{}</span>""".format(host_total_listings_count) + """ other listings locally)</p>114 </div>115 <div class="listingDetailsContainer">116 <p id="listingIDContainer"><a id="listingID" target="_blank" href={}>""".format(listing_url) + """ {}</a>""".format(listing_id) + """</p>117 <p id="listingNameContainer"><a id="listingName" target="_blank" href={}>""".format(listing_url) + """{}</a>""".format(listing_name) + """</p>118 <p id="listingNeighbourhood">{}</p>""".format(neighbourhood_cleansed) + """119 <p id="listingNeighbourhoodDistDuomo">{} meters to the Duomo</p>""".format(dist_duomo) + """120 <p id="listingRoomType">{} ({} bedrooms, accommodates {})</p>""".format(room_type, bedrooms, accommodates) + """121 </div>122 <div id="listingPriceSection" class="listingSection">123 <p class="listingSectionHeadlineContainer">124 <span class="listingSectionHeadline"><span class="dollarSign">â¬</span><span id="listingEstimatedIncomePerYear">{}</span>""".format(rounded_revenue_ltm) + """</span><span id="listingPriceLabel" class="listingSectionHeadlineLabel"> income/year (est.)</span>125 </p>126 <p <span class="listingSectionSubhead"><span class="dollarSign">â¬</span><span id="listingEstimatedIncomePerMonth">{}</span>""".format(monthly_rounded_revenue_ltm) + """</span><span id="listingPriceLabel" class="listingSectionSubhead"> income/month (est.)</span> </p>127 <p class="listingSectionSubhead"><span class="dollarSign">â¬</span><span id="listingPrice">{}</span>""".format(price) + """/night</p>128 </div>129 <div id="listingReviewsSection" class="listingSection">130 <p class="listingSectionHeadlineContainer">131 <span class="listingSectionSubhead"><span id="listingEstimatedNightsPerYear" class="listingSectionHeadline">{}</span>""".format(days_rented_ltm) + """<span class="listingSectionHeadlineLabel"> nights/year (est.)</span></span>132 </p>133 <!-- <p class="listingSectionSubhead"><span id="listingEstimatedOccupancyRate">23.4</span>% occupancy rate (est.)</p> -->134 <p class="listingSectionSubhead"><span id="listingReviewPerMonth">{}</span>""".format(reviews_per_month) + """ reviews/month</p>135 <!-- <p class="listingSectionSubhead"><span id="listingNumberOfReviews">5</span><span id="listingReviewsLabel"> reviews</span></p> -->136 <!-- <p class="listingSectionSubhead">last: <span id="listingLastReview">31/10/2021</span></p> -->137 </div>138 <div id="listingCensusSection" class= "listingSection">139 </div>140 <p class="listingSection">click listing on map to "pin" details</p>141 </div>142 </html>...
views.py
Source:views.py
...24 'categories': categories,25 'listings': listings,26 })27@login_required28def delete_listing(request, listing_id):29 try:30 listing_to_delete = Listing.objects.get(pk=listing_id)31 except:32 return render(request, "auctions/error.html", {33 "error": "404 / Listing doesn't exist."34 })35 if listing_to_delete.user != request.user:36 return render(request, "auctions/error.html", {37 "error": "You can't delete a listing that isn't yours!"38 })39 listing_to_delete.delete()40 return redirect("auctions:index")41 42@login_required43def edit_listing(request, listing_id):44 if request.method == "GET":45 try:46 listing_to_edit = Listing.objects.get(pk=listing_id)47 except:48 return render(request, "auctions/error.html", {49 "error": "404 / Listing doesn't exist."50 })51 if listing_to_edit.user != request.user:52 return render(request, "auctions/error.html", {53 "error": "You can't edit a listing that isn't yours!"54 })55 form = ListingForm(instance=listing_to_edit)56 return render(request, "auctions/edit_listing.html", {57 'form': form,58 'listing': listing_to_edit59 })60 elif request.method == "POST":61 listing_to_update = Listing.objects.get(pk=listing_id)62 form = ListingForm(request.POST or None, instance=listing_to_update)63 if form.is_valid():64 form.save()65 return redirect('auctions:listings', listing_id=listing_id)66 return render(request, 'auctions/edit_listing', {67 'form': form68 })69@login_required70def create_listing(request):71 if request.method == "POST":72 form = ListingForm(request.POST)73 if not form.is_valid():74 return render(request, "auctions/create_listing.html", {75 "form": form,76 })77 else:78 # save the form instance into a new variable, but don't commit to DB79 form_tmp = form.save(commit=False)80 # add the user to the form data81 form_tmp.user = request.user82 # save the form (including current user) to DB83 form_tmp.save()84 return HttpResponseRedirect(reverse("auctions:index"))85 elif request.method == "GET":86 # if user is not authenticated, redirect to login87 if not request.user.is_authenticated:88 return HttpResponseRedirect(reverse("auctions:login"))89 # create unbound form instance90 form = ListingForm()91 return render(request, "auctions/create_listing.html", {92 "form": form93 })94@login_required95def close_listing(request, listing_id):96 try:97 listing_to_close = Listing.objects.get(pk=listing_id)98 except:99 return render(request, "auctions/error.html", {100 "error": "404 / Listing doesn't exist."101 })102 103 if listing_to_close.user != request.user:104 return render(request, "auctions/error.html", {105 "error": "You can't close a listing that isn't yours!"106 })107 else:108 listing_to_close.closed = True109 listing_to_close.save()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!