Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcfbc67d

Browse files
authored
clarify Contact Email on jobs submission form (python#1508)
* clarify Contact Email on jobs submission formAssociates submissions with a user for contact information and addhelp text to clarify that the Contact Email field will be displayedpublically.* address review feedback
1 parent6220867 commitcfbc67d

File tree

6 files changed

+38
-10
lines changed

6 files changed

+38
-10
lines changed

‎jobs/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class JobAdmin(ContentManageableModelAdmin):
1010
filter_horizontal= ['job_types']
1111
list_display= ['__str__','job_title','status','company_name']
1212
list_filter= ['status','telecommuting']
13-
raw_id_fields= ['category']
13+
raw_id_fields= ['category','submitted_by']
1414
search_fields= ['id','job_title']
1515

1616

‎jobs/forms.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ class Meta:
3333
widgets= {
3434
'job_types':CheckboxSelectMultiple(),
3535
}
36+
help_texts= {
37+
'email': (
38+
"<b>This email address will be publicly displayed for "
39+
"applicants to contact if they are interested in the "
40+
"posting.</b>"
41+
),
42+
}
3643

3744
def__init__(self,*args,**kwargs):
3845
super().__init__(*args,**kwargs)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 2.0.13 on 2019-09-06 20:29
2+
3+
fromdjango.confimportsettings
4+
fromdjango.dbimportmigrations,models
5+
importdjango.db.models.deletion
6+
7+
8+
classMigration(migrations.Migration):
9+
10+
dependencies= [
11+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
12+
('jobs','0018_auto_20180705_0352'),
13+
]
14+
15+
operations= [
16+
migrations.AddField(
17+
model_name='job',
18+
name='submitted_by',
19+
field=models.ForeignKey(null=True,on_delete=django.db.models.deletion.SET_NULL,to=settings.AUTH_USER_MODEL),
20+
),
21+
]

‎jobs/models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
fromcms.modelsimportContentManageable,NameSlugModel
1414
fromfastly.utilsimportpurge_url
1515

16+
fromusers.modelsimportUser
17+
1618
from .managersimportJobQuerySet,JobTypeQuerySet,JobCategoryQuerySet
1719
from .signalsimport (
1820
job_was_submitted,job_was_approved,job_was_rejected,comment_was_posted
@@ -109,6 +111,12 @@ class Job(ContentManageable):
109111
null=True,
110112
blank=True)
111113

114+
submitted_by=models.ForeignKey(
115+
User,
116+
null=True,
117+
on_delete=models.SET_NULL,
118+
)
119+
112120
STATUS_DRAFT='draft'
113121
STATUS_REVIEW='review'
114122
STATUS_APPROVED='approved'

‎jobs/tests/test_views.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,6 @@ def test_job_create(self):
320320
creator=User.objects.create_user(username,email,password)
321321
self.client.login(username=creator.username,password='secret')
322322

323-
# Check that the email is already there.
324-
response=self.client.get(url)
325-
self.assertEqual(response.context['form'].initial['email'],email)
326-
327323
response=self.client.post(url,post_data,follow=True)
328324

329325
# Job was saved in draft mode
@@ -380,9 +376,6 @@ def test_job_create_prepopulate_email(self):
380376
password=user_data['password'])
381377
response=self.client.get(create_url)
382378

383-
self.assertEqual(response.context['form'].initial,
384-
{'email':user_data['email']})
385-
386379
deftest_job_types(self):
387380
job_type2=JobTypeFactory(
388381
name='Senior Developer',

‎jobs/views.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,6 @@ def get_success_url(self):
360360
defget_form_kwargs(self):
361361
kwargs=super().get_form_kwargs()
362362
kwargs['request']=self.request
363-
# We don't allow posting a job without logging in to the site.
364-
kwargs['initial']= {'email':self.request.user.email}
365363
returnkwargs
366364

367365
defget_context_data(self,**kwargs):
@@ -371,6 +369,7 @@ def get_context_data(self, **kwargs):
371369

372370
defform_valid(self,form):
373371
form.instance.creator=self.request.user
372+
form.instance.submitted_by=self.request.user
374373
form.instance.status='draft'
375374
returnsuper().form_valid(form)
376375

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp