Skip to content

Commit

Permalink
refactor: Add edit link for job in company_detail.html
Browse files Browse the repository at this point in the history
  • Loading branch information
QA2A committed Sep 5, 2024
1 parent 51ab1cd commit b3a0500
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 378 deletions.
5 changes: 5 additions & 0 deletions website/templates/company_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ <h4 style="margin-bottom: 5px; margin-top: 0px;">{{ job.role|default:job.title|d
{% endif %}
{% endif %}
</h4>
{% if user.is_superuser %}
<a href="{% url 'admin:website_job_change' job.id %}" style="color: black; text-decoration: none;">
<i class="fas fa-edit" style="font-size:20px;"></i>
</a>
{% endif %}

{% if job.salary_min and job.salary_max %}
<p style="margin: 5px 0;">Salary: ${{ job.salary_min|floatformat:0|intcomma }} - ${{ job.salary_max|floatformat:0|intcomma }}</p>
Expand Down
12 changes: 3 additions & 9 deletions website/templates/partials/job_detail_include.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h3>Applications (only visible to you)</h3>
<th>actions</th>
<th>link</th>
<th>email</th>
<td>ping</td>
<th>ping</th>
</tr>
</thead>
{% for application in applications %}
Expand All @@ -29,13 +29,7 @@ <h3>Applications (only visible to you)</h3>
<td>{{ application.date_of_last_email|date:"m/d" }}</td>
<td>{{ application.days_since_last_email }}</td>
<td valign="top" align="right">
<span style="padding-bottom: 3px;
margin-left: 5px;
display: inline-block;
vertical-align: middle">{{ application.email_set.count }}</span>
<div class="email-hover"
style="display: inline-block;
vertical-align: middle">

<a href='https://mail.google.com/mail/u/0/#search/"{{ application.company.name }}"'
target="_blank"
style="margin:0px;
Expand All @@ -54,7 +48,7 @@ <h3>Applications (only visible to you)</h3>
0
{% endfor %}
</div>
</div>

</td>
<td>
<form method="POST"
Expand Down
20 changes: 1 addition & 19 deletions website/templates/website/job_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,6 @@
<th><a href="?{% url_toggle_order request 'posted_date' %}">Posted</a>
</th>


{% if request.GET.show_stage %}
<th>
Stage
</th>
{% endif %}

<th></th>
</tr>

Expand Down Expand Up @@ -244,13 +237,7 @@
{% if job.posted_date %}{{ job.posted_date|timesince }} ago{% endif %}
</td>

{% if request.GET.show_stage %}
<td>
{% for application in job.application_set.all %}
{{ application.stage }}
{% endfor %}
</td>
{% endif %}


<td nowrap>

Expand All @@ -267,12 +254,7 @@

{% if job.link %}
{% if job.link_status_code == 200 %}
<!-- <a href="{{ job.link }}" target="_blank" title="Source Link">
<img src="https://www.google.com/s2/favicons?domain={{ job.link }}"
style="height:20px; border: 1px solid #ccc; border-radius: 5px;">

</a> -->

<a class="apply-button" href="{{ job.link }}" style="display: inline-flex;align-items: center; text-decoration: none; padding: 5px 7px; border: 1px solid #ccc; border-radius: 5px; margin: 0; color: white; " target="_blank" onclick="changeRowColor(this)">
<img src="https://www.google.com/s2/favicons?domain={{ job.link }}"
Expand Down
42 changes: 3 additions & 39 deletions website/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,47 +176,12 @@ def test_job_add_get(self):
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.context["form"], JobForm)


# from selenium import webdriver
# from selenium.webdriver.common.keys import Keys
# from selenium.webdriver.common.by import By
# from selenium.webdriver.support.ui import WebDriverWait
# from selenium.webdriver.support import expected_conditions as EC
# import unittest

# class JobAddFrontendTestCase(unittest.TestCase):
# def setUp(self):
# self.driver = webdriver.Firefox() # You can use any browser driver you want
# self.driver.get('http://localhost:8000/login') # Assuming your Django project is running on localhost:8000 and has a login page
# self.driver.find_element(By.NAME, "username").send_keys('testuser')
# self.driver.find_element(By.NAME, "password").send_keys('12345' + Keys.RETURN)
# WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "userMenu"))) # assuming there is a user menu appearing after login

# def test_job_add(self):
# self.driver.get('http://localhost:8000/job_add') # replace with your job_add URL
# self.driver.find_element(By.NAME, "company").send_keys('Test Company')
# self.driver.find_element(By.NAME, "role").send_keys('Software Developer')
# # Continue the above for all the form fields
# self.driver.find_element(By.CSS_SELECTOR, "form button[type='submit']").click()
# WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "jobList")))
# jobList = self.driver.find_element(By.ID, "jobList").text # assuming jobs are listed in an element with id 'jobList'
# self.assertIn('Test Company', jobList)
# self.assertIn('Software Developer', jobList)
# # Continue the above assertions for all the job fields

# def tearDown(self):
# self.driver.quit()

# if __name__ == "__main__":
# unittest.main()


class AddJobLinkTestCase(TestCase):
def setUp(self):
self.client = APIClient()
self.user = User.objects.create_user(username="testuser", password="12345")
self.client.force_authenticate(user=self.user)
self.add_job_link_url = reverse("add_job_view")
self.add_job_view_url = reverse("add_job_view")
self.role = Role.objects.create(title="Software Developer")
self.company = Company.objects.create(
name="Test Company", email="test+bounce@pingojo.com"
Expand All @@ -230,11 +195,10 @@ def setUp(self):
gmail_id="GEbqgzGslkjhsxkbQKcfvWBQztRFpUIW", application=self.application
)

def test_add_job_link(self):
def test_add_job_view(self):
data = {
"company": self.company.name,
"title": self.role.title,
#'datePosted': '2023-07-05',
"salaryRange": "$50000-$60000",
"companySalary": "",
"description": "This is a test job description.",
Expand All @@ -248,7 +212,7 @@ def test_add_job_link(self):
"link": "https://testurl.com",
}

response = self.client.post(self.add_job_link_url, data, format="json")
response = self.client.post(self.add_job_view_url, data, format="json")
self.assertEqual(
response.status_code, 200
) # Checking that the request was processed successfully
Expand Down
14 changes: 7 additions & 7 deletions website/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
AddJobLink,
ApplicationView,
BouncedEmailAPI,
CompanyJobDetailView,
DashboardView,
DisplayResumeView,
GetCompanyEmailView,
Expand All @@ -31,21 +32,20 @@

urlpatterns = [
path("", views.JobListView.as_view(), name="jobs_list"),
path(
"company/<slug:slug>/", views.CompanyDetailView.as_view(), name="company_detail"
),
#path(
# "company/<slug:slug>/", views.CompanyDetailView.as_view(), name="company_detail"
#),
path("home/", views.home_view, name="home"),
path("resume/<slug:slug>/", views.resume_view, name="resume"),
path("mark-application-as-passed/", views.mark_application_as_passed, name="mark_application_as_passed"),
path('model-counts/', views.model_counts_view, name='model-counts'),
path("company/<slug:slug>/add_job_link/", views.add_job_link, name="add_job_link"),
path("add_email/", views.update_company_email, name="add_email"),
path("dashboard/", DashboardView.as_view(), name="dashboard"),
path(os.environ.get("ADMIN_URL", "admin/"), admin.site.urls),
path("accounts/", include("allauth.urls")),
path("scrape-job/", views.scrape_job, name="scrape-job"),
# path("search/", views.search, name="search"),
path("job/<slug:slug>/", views.JobDetailView.as_view(), name="job_detail"),
path("scrape-job/", views.scrape_job, name="scrape-job"),
path("job/<slug:slug>/", CompanyJobDetailView.as_view(), name="job_detail", kwargs={"type": "job"}),
path("company/<slug:slug>/", CompanyJobDetailView.as_view(), name="company_detail", kwargs={"type": "company"}),
path("privacy-policy/", views.privacy_policy, name="privacy_policy"),
path("terms-of-service/", views.terms_of_service, name="terms_of_service"),
path("favicon.ico", favicon_view),
Expand Down
Loading

0 comments on commit b3a0500

Please sign in to comment.