Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #723 from anjali-dhanuka/description_in_event
Browse files Browse the repository at this point in the history
Added description field in events
  • Loading branch information
abarya authored Aug 1, 2018
2 parents dc7673e + 4419e21 commit 97719cc
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 19 deletions.
2 changes: 1 addition & 1 deletion vms/event/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EventForm(ModelForm):
class Meta:
model = Event
fields = [
'name', 'start_date', 'end_date', 'country', 'state', 'city',
'name', 'description', 'start_date', 'end_date', 'country', 'state', 'city',
'address', 'venue'
]

Expand Down
1 change: 1 addition & 0 deletions vms/event/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Event(models.Model):
r'^[(A-Z)|(a-z)|(0-9)|(\s)|(\.)|(,)|(\-)|(!)|(\')]+$', ),
],
)
description = models.TextField(blank=True)
start_date = models.DateField()
end_date = models.DateField()

Expand Down
37 changes: 29 additions & 8 deletions vms/event/templates/event/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,28 @@
</div>
</div>
{% endif %}

{% if form.description.errors %}
<div class="form-group has-error">
<label class="col-md-2 control-label">{% trans "Description" %}</label>
<div class="col-md-8">
<input class="form-control" placeholder="{% blocktrans %}Description{% endblocktrans %}" type="text" name="description" value="{% if form.description.value %}{{ form.description.value }}{% endif %}">
<p class="help-block">
<strong>
{% for error in form.description.errors %}
{{ error }}
{% endfor %}
</strong>
</p>
</div>
</div>
{% else %}
<div class="form-group">
<label class="col-md-2 control-label">{% trans "Description" %}</label>
<div class="col-md-8">
<input class="form-control" placeholder="{% blocktrans %}Description{% endblocktrans %}" type="text" name="description" value="{% if form.description.value %}{{ form.description.value }}{% endif %}">
</div>
</div>
{% endif %}
{% if form.start_date.errors %}
<div class="form-group has-error">
<label class="col-md-2 control-label">{% trans "Start Date" %}<span class="asteriskField">*</span></label>
Expand Down Expand Up @@ -89,7 +110,7 @@
</div>
</div>
{% endif %}

{% if form.country.errors %}
<div class="form-group has-error">
<label class="col-md-2 control-label">{% trans "Country" %}</label>
Expand All @@ -112,7 +133,7 @@
</div>
</div>
{% endif %}

{% if form.state.errors %}
<div class="form-group has-error">
<label class="col-md-2 control-label">{% trans "State" %}</label>
Expand All @@ -135,7 +156,7 @@
</div>
</div>
{% endif %}

{% if form.city.errors %}
<div class="form-group has-error">
<label class="col-md-2 control-label">{% trans "City" %}</label>
Expand All @@ -158,7 +179,7 @@
</div>
</div>
{% endif %}

{% if form.address.errors %}
<div class="form-group has-error">
<label class="col-md-2 control-label">{% trans "Address" %}</label>
Expand All @@ -181,7 +202,7 @@
</div>
</div>
{% endif %}

{% if form.venue.errors %}
<div class="form-group has-error">
<label class="col-md-2 control-label">{% trans "Venue" %}</label>
Expand All @@ -204,8 +225,8 @@
</div>
</div>
{% endif %}


<div class="form-group">
<div class="col-md-12 col-md-offset-2">
<button class="btn btn-primary" type="submit">{% trans "Create" %}</button>
Expand Down
22 changes: 22 additions & 0 deletions vms/event/templates/event/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@
</div>
</div>
{% endif %}
{% if form.description.errors %}
<div class="form-group has-error">
<label class="col-md-2 control-label">{% trans "Description" %}</label>
<div class="col-md-8">
<input class="form-control" placeholder="{% blocktrans %}Description{% endblocktrans %}" type="text" name="description" value="{% if form.description.value %}{{ form.description.value }}{% endif %}">
<p class="help-block">
<strong>
{% for error in form.description.errors %}
{{ error }}
{% endfor %}
</strong>
</p>
</div>
</div>
{% else %}
<div class="form-group">
<label class="col-md-2 control-label">{% trans "Description" %}</label>
<div class="col-md-8">
<input class="form-control" placeholder="{% blocktrans %}Description{% endblocktrans %}" type="text" name="description" value="{% if form.description.value %}{{ form.description.value }}{% endif %}">
</div>
</div>
{% endif %}
{% if form.start_date.errors %}
<div class="form-group has-error">
<label class="col-md-2 control-label">{% trans "Start Date" %}<span class="asteriskField">*</span></label>
Expand Down
6 changes: 4 additions & 2 deletions vms/event/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ApiForVolaViewTestCase(APITestCase, TestCase):
"""

def setUp(self):
event = ['event', '2015-02-05', '2015-05-05']
event = ['event', '2015-02-05', '2015-05-05', 'event-description']
self.event_1 = create_event_with_details(event)
self.event_1.city = 'city'
self.event_1.state = 'state'
Expand All @@ -27,13 +27,14 @@ def setUp(self):
self.expected_result_one = {'event_name': 'event',
'start_date': '2015-02-05',
'end_date': '2015-05-05',
'description': 'event-description',
'address': 'address',
'city': 'city',
'state': 'state',
'country': 'country',
'venue': 'venue'}

event = ['eventq', '2050-02-05', '2050-05-05']
event = ['eventq', '2050-02-05', '2050-05-05', 'eventq-description']
self.event_2 = create_event_with_details(event)
self.event_2.city = 'cityq'
self.event_2.state = 'stateq'
Expand All @@ -44,6 +45,7 @@ def setUp(self):
self.expected_result_two = {'event_name': 'eventq',
'start_date': '2050-02-05',
'end_date': '2050-05-05',
'description': 'eventq-description',
'address': 'addressq',
'city': 'cityq',
'state': 'stateq',
Expand Down
6 changes: 3 additions & 3 deletions vms/event/tests/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def test_event_details_view(self):
self.assertEqual(event_details_page.get_event_end_date(), 'June 19, 2050')

def test_event_detail_page(self):
# Navgate to event view
created_event = EventDetails.register_valid_event()
# Navigate to event view
created_event = create_event_with_details(['event', '2050-06-11', '2050-06-19', 'event-description'])
event_details_page = self.event_details_page
event_details_page.live_server_url = self.live_server_url
event_details_page.go_to_events_page()
Expand All @@ -88,7 +88,7 @@ def test_event_detail_page(self):
self.assertEqual(event_details_page.get_event_name(), created_event.name)
self.assertEqual(event_details_page.get_event_start_date(), 'June 11, 2050')
self.assertEqual(event_details_page.get_event_end_date(), 'June 19, 2050')

self.assertEqual(event_details_page.get_event_description(), 'event-description')

def test_valid_event_create(self):
created_event = EventDetails.register_valid_event()
Expand Down
3 changes: 2 additions & 1 deletion vms/event/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def create_event():
return created_event

def test_valid_model_create(self):
event = ['event-name', '2050-05-24', '2050-05-28']
event = ['event-name', '2050-05-24', '2050-05-28', 'event-description']
create_event_with_details(event)

# Check database for instance creation
Expand All @@ -37,6 +37,7 @@ def test_valid_model_create(self):
self.assertEqual(event_in_db.name, event[0])
self.assertEqual(str(event_in_db.start_date), event[1])
self.assertEqual(str(event_in_db.end_date), event[2])
self.assertEqual(event_in_db.description, event[3])

def test_invalid_model_create(self):
event = ['event~name', '2050-05-21', '2050-05-24']
Expand Down
1 change: 1 addition & 0 deletions vms/event/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def return_event_data(self, events):
event_data['event_name'] = event.name
event_data['start_date'] = event.start_date
event_data['end_date'] = event.end_date
event_data['description'] = event.description
event_data['address'] = event.address
event_data['city'] = event.city
event_data['state'] = event.state
Expand Down
4 changes: 2 additions & 2 deletions vms/pom/locators/eventsPageLocators.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class EventsPageLocators(object):
ORG_NAME = '//input[@name = "name"]'

EVENT_NAME_ERROR = "//form//div[1]/div/p/strong"
EVENT_START_DATE_ERROR = "//form//div[2]/div/p/strong"
EVENT_END_DATE_ERROR = "//form//div[3]/div/p/strong"
EVENT_START_DATE_ERROR = "//form//div[3]/div/p/strong"
EVENT_END_DATE_ERROR = "//form//div[4]/div/p/strong"
JOB_NAME_ERROR = "//form//div[3]/div/p/strong"
JOB_START_DATE_ERROR = "//form//div[5]/div/p/strong"
JOB_END_DATE_ERROR = "//form//div[6]/div/p/strong"
Expand Down
3 changes: 3 additions & 0 deletions vms/pom/pages/eventsPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def go_to_create_event_page(self):
def go_to_details_event_page(self):
self.element_by_xpath(self.elements.VIEW_EVENT).click()

def get_event_description(self):
return self.element_by_xpath('//div[@class="panel-body"]').text

def go_to_edit_event_page(self):
self.element_by_xpath(self.elements.EDIT_EVENT).click()

Expand Down
7 changes: 5 additions & 2 deletions vms/shift/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ def create_edit_request_with_details(start_time, end_time, logged_shift):
def create_event_with_details(event):
"""
Creates and returns event with passed name and dates
"""
e1 = Event(name=event[0], start_date=event[1], end_date=event[2])
"""
if len(event) == 4:
e1 = Event(name=event[0], start_date=event[1], end_date=event[2], description=event[3])
else:
e1 = Event(name=event[0], start_date=event[1], end_date=event[2])
e1.save()
return e1

Expand Down

0 comments on commit 97719cc

Please sign in to comment.