Skip to content

Commit f637ef0

Browse files
committed
add a presents logo
For #46
1 parent cb8362a commit f637ef0

File tree

6 files changed

+143
-7
lines changed

6 files changed

+143
-7
lines changed

client/skr/models/Event.coffee

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Skr.Models.Event extends Skr.Models.Base
1717

1818
associations:
1919
photo: { model: "Lanes.Models.Asset" }
20+
presents_logo: { model: "Lanes.Models.Asset" }
2021
sku: { model: "Sku", required: true }
2122
invoices: { collection: "Invoice" }
2223
invoice_lines: { collection: "InvLine" }

client/skr/screens/events/Events.cjsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Skr.Screens.Events extends Skr.Screens.Base
22

33
syncOptions:
4-
include: [ 'sku', 'photo' ]
4+
include: [ 'sku', 'photo', 'presents_logo' ]
55

66
modelBindings:
77
event: ->
@@ -45,8 +45,12 @@ class Skr.Screens.Events extends Skr.Screens.Base
4545
<LC.Input sm=12 name='venue' model={@event} />
4646
</BS.Row>
4747
<BS.Row>
48-
<LC.ImageAsset sm=5 asset={@event.photo}
49-
label='Photo' size='medium' />
48+
<LC.FieldSet title="Logos" sm=12>
49+
<LC.ImageAsset sm=6 asset={@event.photo}
50+
label='Photo' size='thumb' />
51+
<LC.ImageAsset sm=6 asset={@event.presents_logo}
52+
label='Presents Logo' size='thumb' />
53+
</LC.FieldSet>
5054
</BS.Row>
5155

5256
</LC.ScreenWrapper>

db/schema.sql

+106-2
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ CREATE TABLE skr_events (
472472
id integer NOT NULL,
473473
code character varying NOT NULL,
474474
sku_id integer NOT NULL,
475-
title text,
475+
title text NOT NULL,
476476
sub_title text,
477477
info text,
478478
venue text,
@@ -2115,6 +2115,39 @@ CREATE SEQUENCE system_settings_id_seq
21152115
ALTER SEQUENCE system_settings_id_seq OWNED BY system_settings.id;
21162116

21172117

2118+
--
2119+
-- Name: testers; Type: TABLE; Schema: public; Owner: -
2120+
--
2121+
2122+
CREATE TABLE testers (
2123+
id integer NOT NULL,
2124+
name character varying,
2125+
email character varying,
2126+
visits text[] DEFAULT '{}'::text[],
2127+
created_at timestamp without time zone NOT NULL,
2128+
updated_at timestamp without time zone NOT NULL
2129+
);
2130+
2131+
2132+
--
2133+
-- Name: testers_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2134+
--
2135+
2136+
CREATE SEQUENCE testers_id_seq
2137+
START WITH 1
2138+
INCREMENT BY 1
2139+
NO MINVALUE
2140+
NO MAXVALUE
2141+
CACHE 1;
2142+
2143+
2144+
--
2145+
-- Name: testers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
2146+
--
2147+
2148+
ALTER SEQUENCE testers_id_seq OWNED BY testers.id;
2149+
2150+
21182151
--
21192152
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
21202153
--
@@ -2416,6 +2449,13 @@ ALTER TABLE ONLY skr_vouchers ALTER COLUMN id SET DEFAULT nextval('skr_vouchers_
24162449
ALTER TABLE ONLY system_settings ALTER COLUMN id SET DEFAULT nextval('system_settings_id_seq'::regclass);
24172450

24182451

2452+
--
2453+
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
2454+
--
2455+
2456+
ALTER TABLE ONLY testers ALTER COLUMN id SET DEFAULT nextval('testers_id_seq'::regclass);
2457+
2458+
24192459
--
24202460
-- Name: ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
24212461
--
@@ -2784,6 +2824,14 @@ ALTER TABLE ONLY system_settings
27842824
ADD CONSTRAINT system_settings_pkey PRIMARY KEY (id);
27852825

27862826

2827+
--
2828+
-- Name: testers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
2829+
--
2830+
2831+
ALTER TABLE ONLY testers
2832+
ADD CONSTRAINT testers_pkey PRIMARY KEY (id);
2833+
2834+
27872835
--
27882836
-- Name: index_assets_on_owner_id_and_owner_type; Type: INDEX; Schema: public; Owner: -
27892837
--
@@ -3657,6 +3705,62 @@ ALTER TABLE ONLY skr_vouchers
36573705

36583706
SET search_path TO "$user", public;
36593707

3660-
INSERT INTO schema_migrations (version) VALUES ('1'), ('2'), ('20120110142845'), ('20140202185309'), ('20140202193316'), ('20140202193318'), ('20140202193319'), ('20140202193700'), ('20140202194700'), ('20140213040608'), ('20140220031700'), ('20140220031800'), ('20140220190836'), ('20140220203029'), ('20140224034759'), ('20140225032853'), ('20140320030501'), ('20140321031604'), ('20140322012143'), ('20140322014401'), ('20140322023453'), ('20140322035024'), ('20140322223912'), ('20140322223920'), ('20140323001446'), ('20140327202102'), ('20140327202107'), ('20140327202207'), ('20140327202209'), ('20140327214000'), ('20140327223002'), ('20140327224000'), ('20140327224002'), ('20140330232808'), ('20140330232810'), ('20140400164729'), ('20140400164733'), ('20140401164729'), ('20140401164740'), ('20140422024010'), ('20140615031600'), ('20151121211323'), ('20160216142845'), ('20160229002044'), ('20160229041711'), ('20160307022705'), ('20160517032350'), ('20160531014306'), ('20160604195848'), ('20160605024432'), ('20160608023553'), ('20160620010455'), ('20160726004411'), ('20160805002717'), ('20161219174024');
3708+
INSERT INTO schema_migrations (version) VALUES
3709+
('1'),
3710+
('2'),
3711+
('20120110142845'),
3712+
('20140202185309'),
3713+
('20140202193316'),
3714+
('20140202193318'),
3715+
('20140202193319'),
3716+
('20140202193700'),
3717+
('20140202194700'),
3718+
('20140213040608'),
3719+
('20140220031700'),
3720+
('20140220031800'),
3721+
('20140220190836'),
3722+
('20140220203029'),
3723+
('20140224034759'),
3724+
('20140225032853'),
3725+
('20140320030501'),
3726+
('20140321031604'),
3727+
('20140322012143'),
3728+
('20140322014401'),
3729+
('20140322023453'),
3730+
('20140322035024'),
3731+
('20140322223912'),
3732+
('20140322223920'),
3733+
('20140323001446'),
3734+
('20140327202102'),
3735+
('20140327202107'),
3736+
('20140327202207'),
3737+
('20140327202209'),
3738+
('20140327214000'),
3739+
('20140327223002'),
3740+
('20140327224000'),
3741+
('20140327224002'),
3742+
('20140330232808'),
3743+
('20140330232810'),
3744+
('20140400164729'),
3745+
('20140400164733'),
3746+
('20140401164729'),
3747+
('20140401164740'),
3748+
('20140422024010'),
3749+
('20140615031600'),
3750+
('20150220015108'),
3751+
('20151121211323'),
3752+
('20160216142845'),
3753+
('20160229002044'),
3754+
('20160229041711'),
3755+
('20160307022705'),
3756+
('20160517032350'),
3757+
('20160531014306'),
3758+
('20160604195848'),
3759+
('20160605024432'),
3760+
('20160608023553'),
3761+
('20160620010455'),
3762+
('20160726004411'),
3763+
('20160805002717'),
3764+
('20161219174024');
36613765

36623766

lib/skr/models/event.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ class Event < Model
55
has_code_identifier from: :title
66

77
has_one :photo, as: :owner, :class_name=>'Lanes::Asset',
8-
export: { writable: false }, :dependent => :destroy
8+
export: { writable: true }, dependent: :destroy
9+
10+
has_one :presents_logo, -> { where owner_type: "PresentsLogo"},
11+
class_name: 'Lanes::Asset', foreign_key: :owner_id,
12+
foreign_type: :owner_type, dependent: :destroy,
13+
export: { writable: true }
914

1015
belongs_to :sku, export: { writable: true }
1116

@@ -26,6 +31,10 @@ def qty_remaining
2631
end
2732
end
2833

34+
def get_presents_logo
35+
presents_logo.present? ? presents_logo : Location.default.get_logo
36+
end
37+
2938
end
3039

3140
end

spec/server/models/event_spec.rb

+18
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,22 @@ class EventSpec < Skr::TestCase
2828
assert_equal event.invoices.first, invoice
2929
end
3030

31+
it 'can set photos' do
32+
fixtures_path = Pathname.new(__FILE__).dirname.join("../../fixtures")#.expand_path
33+
34+
event = skr_event(:top)
35+
Tempfile.open do |tf1|
36+
tf1.write fixtures_path.join('generic-band.jpg').read
37+
tf1.rewind
38+
Tempfile.open do |tf2|
39+
tf2.write fixtures_path.join('stockor.png').read
40+
tf2.rewind
41+
event.build_photo(file: tf1)
42+
event.build_presents_logo(file: tf2)
43+
assert_saves event
44+
end
45+
end
46+
47+
end
48+
3149
end

templates/print/types/invoice/ticket.tex.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
\renewcommand{\ticketdefault}{%
1515
\put(49,45){
16-
<% if (logo = @invoice.location.get_logo).present? -%>
16+
<% if (logo = event.get_presents_logo).present? -%>
1717
\raisebox{-1mm}{\includegraphics[height=8mm]{<%= logo.file[:original].download.path %>}}
1818
<% end -%>
1919
\textsf{\Huge presents:}

0 commit comments

Comments
 (0)